Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell98 |
Synopsis
- newtype Chunk a = Chunk { }
- chunked :: (a -> a -> a) -> Chunk a -> Chunk a -> Chunk a
- listToChunk :: Semigroup a => [a] -> Chunk a
- (<<+>>) :: Chunk Doc -> Chunk Doc -> Chunk Doc
- (<</>>) :: Chunk Doc -> Chunk Doc -> Chunk Doc
- vcatChunks :: [ Chunk Doc ] -> Chunk Doc
- vsepChunks :: [ Chunk Doc ] -> Chunk Doc
- isEmpty :: Chunk a -> Bool
- stringChunk :: String -> Chunk Doc
- paragraph :: String -> Chunk Doc
- extractChunk :: Monoid a => Chunk a -> a
- tabulate :: Int -> [( Doc , Doc )] -> Chunk Doc
- chunkFlatAlt :: Chunk Doc -> Chunk Doc -> Chunk Doc
- chunkIsEffectivelyEmpty :: Chunk Doc -> Bool
Documentation
The free monoid on a semigroup
a
.
Instances
Monad Chunk Source # | |
Functor Chunk Source # | |
Applicative Chunk Source # | |
Alternative Chunk Source # | |
MonadPlus Chunk Source # | |
Eq a => Eq ( Chunk a) Source # | |
Show a => Show ( Chunk a) Source # | |
Semigroup a => Semigroup ( Chunk a) Source # | |
Semigroup a => Monoid ( Chunk a) Source # | |
CanAnnotate ( Chunk Doc ) Source # | |
chunked :: (a -> a -> a) -> Chunk a -> Chunk a -> Chunk a Source #
Given a semigroup structure on
a
, return a monoid structure on 'Chunk a'.
Note that this is
not
the same as
liftA2
.
listToChunk :: Semigroup a => [a] -> Chunk a Source #
Concatenate a list into a Chunk.
listToChunk
satisfies:
isEmpty . listToChunk = null listToChunk = mconcat . fmap pure
vsepChunks :: [ Chunk Doc ] -> Chunk Doc Source #
Concatenate
Chunk
s vertically separated by empty lines.
paragraph :: String -> Chunk Doc Source #
Convert a paragraph into a
Chunk
. The resulting chunk is composed by the
words of the original paragraph separated by softlines, so it will be
automatically word-wrapped when rendering the underlying document.
This satisfies:
isEmpty . paragraph = null . words
extractChunk :: Monoid a => Chunk a -> a Source #
Part of a constrained comonad instance.
This is the counit of the adjunction between
Chunk
and the forgetful
functor from monoids to semigroups. It satisfies:
extractChunk . pure = id extractChunk . fmap pure = id