optparse-applicative-0.18.1.0: Utilities and combinators for parsing command line options

Safe Haskell | Safe-Inferred
Language | Haskell98

Options.Applicative.Help.Chunk

Synopsis

- newtype Chunk a = Chunk {
  - unChunk :: Maybe a
  }
- 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

# Documentation

newtype Chunk a #

The free monoid on a semigroup `a`.

Constructors

Chunk |
Fields unChunk :: Maybe a

#### Instances

Instances details

Alternative Chunk # |
Instance details Defined in Options.Applicative.Help.Chunk Methods empty :: Chunk a # (<|>) :: Chunk a -> Chunk a -> Chunk a # some :: Chunk a -> Chunk [a] # many :: Chunk a -> Chunk [a] #
Applicative Chunk # |
Instance details Defined in Options.Applicative.Help.Chunk Methods pure :: a -> Chunk a # (<*>) :: Chunk (a -> b) -> Chunk a -> Chunk b # liftA2 :: (a -> b -> c) -> Chunk a -> Chunk b -> Chunk c # (*>) :: Chunk a -> Chunk b -> Chunk b # (<*) :: Chunk a -> Chunk b -> Chunk a #
Functor Chunk # |
Instance details Defined in Options.Applicative.Help.Chunk Methods fmap :: (a -> b) -> Chunk a -> Chunk b # (<$) :: a -> Chunk b -> Chunk a #
Monad Chunk # |
Instance details Defined in Options.Applicative.Help.Chunk Methods (>>=) :: Chunk a -> (a -> Chunk b) -> Chunk b # (>>) :: Chunk a -> Chunk b -> Chunk b # return :: a -> Chunk a #
MonadPlus Chunk # |
Instance details Defined in Options.Applicative.Help.Chunk Methods mzero :: Chunk a # mplus :: Chunk a -> Chunk a -> Chunk a #
Semigroup a => Monoid (Chunk a) # |
Instance details Defined in Options.Applicative.Help.Chunk Methods mempty :: Chunk a # mappend :: Chunk a -> Chunk a -> Chunk a # mconcat :: [Chunk a] -> Chunk a #
Semigroup a => Semigroup (Chunk a) # |
Instance details Defined in Options.Applicative.Help.Chunk Methods (<>) :: Chunk a -> Chunk a -> Chunk a # sconcat :: NonEmpty (Chunk a) -> Chunk a # stimes :: Integral b => b -> Chunk a -> Chunk a #
Show a => Show (Chunk a) # |
Instance details Defined in Options.Applicative.Help.Chunk Methods showsPrec :: Int -> Chunk a -> ShowS # show :: Chunk a -> String # showList :: [Chunk a] -> ShowS #
Eq a => Eq (Chunk a) # |
Instance details Defined in Options.Applicative.Help.Chunk Methods (==) :: Chunk a -> Chunk a -> Bool # (/=) :: Chunk a -> Chunk a -> Bool #

chunked :: (a -> a -> a) -> Chunk a -> Chunk a -> Chunk a #

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 #

Concatenate a list into a Chunk. `listToChunk` satisfies:

    isEmpty . listToChunk = null
    listToChunk = mconcat . fmap pure

(<<+>>) :: Chunk Doc -> Chunk Doc -> Chunk Doc #

Concatenate two `Chunk`s with a space in between. If one is empty, this just returns the other one.

Unlike `<+>` for `Doc`, this operation has a unit element, namely the empty `Chunk`.

(<</>>) :: Chunk Doc -> Chunk Doc -> Chunk Doc #

Concatenate two `Chunk`s with a softline in between. This is exactly like `<<+>>`, but uses a softline instead of a space.

vcatChunks :: [Chunk Doc] -> Chunk Doc #

Concatenate `Chunk`s vertically.

vsepChunks :: [Chunk Doc] -> Chunk Doc #

Concatenate `Chunk`s vertically separated by empty lines.

isEmpty :: Chunk a -> Bool #

Whether a `Chunk` is empty. Note that something like 'pure mempty' is not considered an empty chunk, even though the underlying `Doc` is empty.

stringChunk :: String -> Chunk Doc #

Convert a `String` into a `Chunk`. This satisfies:

    isEmpty . stringChunk = null
    extractChunk . stringChunk = string

paragraph :: String -> Chunk Doc #

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 #

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

tabulate :: Int -> [(Doc, Doc)] -> Chunk Doc #

Display pairs of strings in a table.