cabal: bump version
[haskell/symantic-plaintext.git] / Symantic / Document / Plain.hs
index 343cb42c18e7ef0cb613d200a80480a445e7cc1b..60fefd12aa0589786c54cb13a17f3d7f708fe0b4 100644 (file)
@@ -123,8 +123,8 @@ instance Lengthable d => Lengthable (PlainChunk d) where
         PlainChunk_Ignored{} -> True
         PlainChunk_Word d -> nullLength d
         PlainChunk_Spaces s -> s == 0
-instance DocFrom [SGR] d => DocFrom [SGR] (PlainChunk d) where
-       docFrom sgr = PlainChunk_Ignored (docFrom sgr)
+instance From [SGR] d => From [SGR] (PlainChunk d) where
+       from sgr = PlainChunk_Ignored (from sgr)
 
 runPlainChunk :: Spaceable d => PlainChunk d -> d
 runPlainChunk = \case
@@ -178,8 +178,8 @@ instance (Spaceable d) => Spaceable (Plain d) where
                         Just width | width < newWidth ->
                                overflow $ k ((spaces n <>), newState) fits fits
                         _ -> k ((spaces n <>), newState) fits overflow
-instance (DocFrom (Word s) d, Semigroup d, Lengthable s) => DocFrom (Word s) (Plain d) where
-       docFrom s = Plain $ \inh st@PlainState{..} k fits overflow ->
+instance (From (Word s) d, Semigroup d, Lengthable s) => From (Word s) (Plain d) where
+       from s = Plain $ \inh st@PlainState{..} k fits overflow ->
                let wordLen = length s in
                if wordLen <= 0
                then k (id,st) fits overflow
@@ -190,7 +190,7 @@ instance (DocFrom (Word s) d, Semigroup d, Lengthable s) => DocFrom (Word s) (Pl
                        then
                                let newState = st
                                         { plainState_buffer =
-                                               PlainChunk_Word (Word (docFrom s)) :
+                                               PlainChunk_Word (Word (from s)) :
                                                plainState_buffer
                                         , plainState_bufferWidth = newBufferWidth
                                         } in
@@ -204,14 +204,14 @@ instance (DocFrom (Word s) d, Semigroup d, Lengthable s) => DocFrom (Word s) (Pl
                                         } in
                                case plainInh_width inh of
                                 Just width | width < newWidth ->
-                                       overflow $ k ((docFrom s <>), newState) fits fits
-                                _ -> k ((docFrom s <>), newState) fits overflow
-instance (DocFrom (Word s) d, Lengthable s, Spaceable d, Splitable s) =>
-         DocFrom (Line s) (Plain d) where
-       docFrom =
+                                       overflow $ k ((from s <>), newState) fits fits
+                                _ -> k ((from s <>), newState) fits overflow
+instance (From (Word s) d, Lengthable s, Spaceable d, Splitable s) =>
+         From (Line s) (Plain d) where
+       from =
                mconcat .
                List.intersperse breakspace .
-               (docFrom <$>) .
+               (from <$>) .
                words .
                unLine
 instance Spaceable d => Indentable (Plain d) where
@@ -316,44 +316,44 @@ instance (Spaceable d) => Wrappable (Plain d) where
                        unPlain y inh st k fits overflow
                 )
 -- String
-instance (DocFrom (Word String) d, Spaceable d) =>
-         DocFrom String (Plain d) where
-       docFrom =
+instance (From (Word String) d, Spaceable d) =>
+         From String (Plain d) where
+       from =
                mconcat .
                List.intersperse newline .
-               (docFrom <$>) .
+               (from <$>) .
                lines
-instance (DocFrom (Word String) d, Spaceable d) =>
+instance (From (Word String) d, Spaceable d) =>
          IsString (Plain d) where
-       fromString = docFrom
+       fromString = from
 -- Text
-instance (DocFrom (Word Text) d, Spaceable d) =>
-         DocFrom Text (Plain d) where
-       docFrom =
+instance (From (Word Text) d, Spaceable d) =>
+         From Text (Plain d) where
+       from =
                mconcat .
                List.intersperse newline .
-               (docFrom <$>) .
+               (from <$>) .
                lines
-instance (DocFrom (Word TL.Text) d, Spaceable d) =>
-         DocFrom TL.Text (Plain d) where
-       docFrom =
+instance (From (Word TL.Text) d, Spaceable d) =>
+         From TL.Text (Plain d) where
+       from =
                mconcat .
                List.intersperse newline .
-               (docFrom <$>) .
+               (from <$>) .
                lines
 -- Char
-instance (DocFrom (Word Char) d, Spaceable d) =>
-         DocFrom Char (Plain d) where
-       docFrom ' '  = breakspace
-       docFrom '\n' = newline
-       docFrom c    = docFrom (Word c)
+instance (From (Word Char) d, Spaceable d) =>
+         From Char (Plain d) where
+       from ' '  = breakspace
+       from '\n' = newline
+       from c    = from (Word c)
 
 
-instance (DocFrom [SGR] d, Semigroup d) => DocFrom [SGR] (Plain d) where
-       docFrom sgr = Plain $ \inh st k ->
+instance (From [SGR] d, Semigroup d) => From [SGR] (Plain d) where
+       from sgr = Plain $ \inh st k ->
                if plainInh_justify inh
-               then k (id, st {plainState_buffer = PlainChunk_Ignored (docFrom sgr) : plainState_buffer st})
-               else k ((docFrom sgr <>), st)
+               then k (id, st {plainState_buffer = PlainChunk_Ignored (from sgr) : plainState_buffer st})
+               else k ((from sgr <>), st)
 
 joinLine ::
  Spaceable d =>