doctemplates-0.11.0.1: Pandoc-style document templates

Copyright | Copyright (C) 2009-2019 John MacFarlane
License | BSD3
Maintainer | John MacFarlane <jgm@berkeley.edu>
Stability | alpha
Portability | portable
Safe Haskell | None
Language | Haskell2010

Text.DocTemplates

Description

This is the text templating system used by pandoc. Its basic function is to fill variables in a template. Variables are provided by a “context.” Any instance of the `ToContext` typeclass (such as an aeson `Value`) can serve as the context, or a `Context` value can be constructed manually.

Control structures are provided to test whether a variable has a non-blank value and to iterate over the items of a list. Partials—that is, subtemplates defined in different files—are supported. Pipes can be used to transform the values of variables or partials. The provided pipes make it possible to do list enumeration and tabular layout in templates.

Templates are rendered to a doclayout `Doc` (which is polymorphic in the underlying string type). If `Doc` values are used in the context, rendered documents will be able to wrap flexibly on breaking spaces. This feature makes doctemplates more suitable than other template engines for plain-text formats (like Markdown).

Unlike the various HTML-centered template engines, doctemplates is output-format agnostic, so no automatic escaping is done on interpolated values. Values are assumed to be escaped properly in the Context.

## Example of use

    {-# LANGUAGE OverloadedStrings #-}
    import Data.Text (Text)
    import qualified Data.Text.IO as T
    import Data.Aeson
    import Text.DocTemplates
    import Text.DocLayout (render)

    data Employee = Employee { firstName :: String
                             , lastName  :: String
                             , salary    :: Maybe Int }
    instance ToJSON Employee where
      toJSON e = object [ "name" .= object [ "first" .= firstName e
                                           , "last"  .= lastName e ]
                        , "salary" .= salary e ]

    template :: Text
    template = "$for(employee)$Hi, $employee.name.first$. $if(employee.salary)$You make $employee.salary$.$else$No salary data.$endif$$sep$\n$endfor$"

    main :: IO ()
    main = do
      res <- compileTemplate "mytemplate.txt" template
      case res of
             Left e    -> error e
             Right t   -> T.putStrLn $ render Nothing $ renderTemplate t $ object
                            ["employee" .=
                              [ Employee "John" "Doe" Nothing
                              , Employee "Omar" "Smith" (Just 30000)
                              , Employee "Sara" "Chen" (Just 60000) ]
                            ]

## Delimiters

To mark variables and control structures in the template, either `$`…`$` or `${`…`}` may be used as delimiters. The styles may also be mixed in the same template, but the opening and closing delimiter must match in each case. The opening delimiter may be followed by one or more spaces or tabs, which will be ignored. The closing delimiter may be followed by one or more spaces or tabs, which will be ignored.

To include a literal `$` in the document, use `$$`.

## Comments

Anything between the sequence `$--` and the end of the line will be treated as a comment and omitted from the output.

## Interpolated variables

A slot for an interpolated variable is a variable name surrounded by matched delimiters. Variable names must begin with a letter and can contain letters, numbers, `_`, `-`, and `.`. The keywords `it`, `if`, `else`, `endif`, `for`, `sep`, and `endfor` may not be used as variable names. Examples:

    $foo$
    $foo.bar.baz$
    $foo_bar.baz-bim$
    $ foo $
    ${foo}
    ${foo.bar.baz}
    ${foo_bar.baz-bim}
    ${ foo }

The values of variables are determined by the `Context` that is passed as a parameter to `renderTemplate`. So, for example, `title` will return the value of the `title` field, and `employee.salary` will return the value of the `salary` field of the object that is the value of the `employee` field.

- If the value of the variable is simple value, it will be rendered verbatim. (Note that no escaping is done; the assumption is that the calling program will escape the strings appropriately for the output format.)
- If the value of the variable is a boolean value, it will be rendered as `true` if true, or as empty if false.
- If the value is a list, the values will be concatenated.
- If the value is a map, the string `true` will be rendered.
- Every other value will be rendered as the empty string.

When a `Context` is derived from an aeson (JSON) `Value`, the following conversions are done:

- If the value is a number, it will be rendered as an integer if possible, otherwise as a floating-point number.

## Conditionals

A conditional begins with `if(variable)` (enclosed in matched delimiters) and ends with `endif` (enclosed in matched delimiters). It may optionally contain an `else` (enclosed in matched delimiters). The `if` section is used if `variable` has a true value, otherwise the `else` section is used (if present). The following values count as true:

- any map
- any array containing at least one true value
- any nonempty string (even `false`)
- boolean True

Examples:

    $if(foo)$bar$endif$

    $if(foo)$
      $foo$
    $endif$

    $if(foo)$
    part one
    $else$
    part two
    $endif$

    ${if(foo)}bar${endif}

    ${if(foo)}
      ${foo}
    ${endif}

    ${if(foo)}
    ${ foo.bar }
    ${else}
    no foo!
    ${endif}

The keyword `elseif` may be used to simplify complex nested conditionals. Thus

    $if(foo)$
    XXX
    $elseif(bar)$
    YYY
    $else$
    ZZZ
    $endif$

is equivalent to

    $if(foo)$
    XXX
    $else$
    $if(bar)$
    YYY
    $else$
    ZZZ
    $endif$
    $endif$

## For loops

A for loop begins with `for(variable)` (enclosed in matched delimiters) and ends with `endfor` (enclosed in matched delimiters.

- If `variable` is an array, the material inside the loop will be evaluated repeatedly, with `variable` being set to each value of the array in turn, and concatenated.
- If `variable` is a map, the material inside will be set to the map.
- If the value of the associated variable is not an array or a map, a single iteration will be performed on its value.

Examples:

    $for(foo)$$foo$$sep$, $endfor$

    $for(foo)$
      - $foo.last$, $foo.first$
    $endfor$

    ${ for(foo.bar) }
      - ${ foo.bar.last }, ${ foo.bar.first }
    ${ endfor }

    $for(mymap)$
    $it.name$: $it.office$
    $endfor$

You may optionally specify a separator between consecutive values using `sep` (enclosed in matched delimiters). The material between `sep` and the `endfor` is the separator.

    ${ for(foo) }${ foo }${ sep }, ${ endfor }

Instead of using `variable` inside the loop, the special anaphoric keyword `it` may be used.

    ${ for(foo.bar) }
      - ${ it.last }, ${ it.first }
    ${ endfor }

## Partials

Partials (subtemplates stored in different files) may be included using the syntax

    ${ boilerplate() }

The partials are obtained using `getPartial` from the `TemplateMonad` class. This may be implemented differently in different monads. The path passed to `getPartial` is computed on the basis of the original template path (a parameter to `compileTemplate`) and the partial’s name. The partial’s name is substituted for the base name of the original template path (leaving the original template’s extension), unless the partial has an explicit extension, in which case this is kept. So, with the `TemplateMonad` instance for IO, partials will be sought in the directory containing the main template, and will be assumed to have the extension of the main template.

Partials may optionally be applied to variables using a colon:

    ${ date:fancy() }

    ${ articles:bibentry() }

If `articles` is an array, this will iterate over its values, applying the partial `bibentry()` to each one. So the second example above is equivalent to

    ${ for(articles) }
    ${ it:bibentry() }
    ${ endfor }

Note that the anaphoric keyword `it` must be used when iterating over partials. In the above examples, the `bibentry` partial should contain `it.title` (and so on) instead of `articles.title`.

Final newlines are omitted from included partials.

Partials may include other partials. If you exceed a nesting level of 50, though, in resolving partials, the literal `(loop)` will be returned, to avoid infinite loops.

A separator between values of an array may be specified in square brackets, immediately after the variable name or partial:

    ${months[, ]}$

    ${articles:bibentry()[; ]$

The separator in this case is literal and (unlike with `sep` in an explicit `for` loop) cannot contain interpolated variables or other template directives.

## Nesting

To ensure that content is “nested,” that is, subsequent lines indented, use the `^` directive:

    $item.number$  $^$$item.description$ ($item.price$)

In this example, if `item.description` has multiple lines, they will all be indented to line up with the first line:

    00123  A fine bottle of 18-year old
           Oban whiskey. ($148)

To nest multiple lines to the same level, align them with the `^` directive in the template. For example:

    $item.number$  $^$$item.description$ ($item.price$)
                   (Available til $item.sellby$.)

will produce

    00123  A fine bottle of 18-year old
           Oban whiskey. ($148)
           (Available til March 30, 2020.)

If a variable occurs by itself on a line, preceded by whitespace and not followed by further text or directives on the same line, and the variable’s value contains multiple lines, it will be nested automatically.

## Breakable spaces

When rendering to a `Doc`, a distinction can be made between breakable and unbreakable spaces. Normally, spaces in the template itself (as opposed to values of the interpolated variables) are not breakable, but they can be made breakable in part of the template by using the `~` keyword (ended with another `~`).

    $~$This long line may break if the document is rendered
    with a short line length.$~$

The `~` keyword has no effect when rendering to `Text` or `String`.

## Pipes

A pipe transforms the value of a variable or partial. Pipes are specified using a slash (`/`) between the variable name (or partial) and the pipe name. Example:

    $for(name)$
    $name/uppercase$
    $endfor$

    $for(metadata/pairs)$
    - $it.key$: $it.value$
    $endfor$

    $employee:name()/uppercase$

Pipes may be chained:

    $for(employees/pairs)$
    $it.key/alpha/uppercase$. $it.name$
    $endfor$

Some pipes take parameters:

    |----------------------|------------|
    $for(employee)$
    $it.name.first/uppercase/left 20 "| "$$it.name.salary/right 10 " | " " |"$
    $endfor$
    |----------------------|------------|

Currently the following pipes are predefined:

- `pairs`: Converts a map or array to an array of maps, each with `key` and `value` fields. If the original value was an array, the `key` will be the array index, starting with 1.
- `first`: Returns the first value of an array, if applied to a non-empty array; otherwise returns the original value.
- `last`: Returns the last value of an array, if applied to a non-empty array; otherwise returns the original value.
- `rest`: Returns all but the first value of an array, if applied to a non-empty array; otherwise returns the original value.
- `allbutlast`: Returns all but the last value of an array, if applied to a non-empty array; otherwise returns the original value.
- `uppercase`: Converts text to uppercase.
- `lowercase`: Converts text to lowercase.
- `length`: Returns the length of the value: number of characters for a textual value, number of elements for a map or array.
- `reverse`: Reverses a textual value or array, and has no effect on other values.
- `chomp`: Removes trailing newlines (and breakable space).
- `nowrap`: Disables line wrapping on breakable spaces.
- `alpha`: Converts textual values that can be read as an integer into lowercase alphabetic characters `a..z` (mod 26). This can be used to get lettered enumeration from array indices. To get uppercase letters, chain with `uppercase`.
- `roman`: Converts textual values that can be read as an integer into lowercase roman numerials. This can be used to get lettered enumeration from array indices. To get uppercase roman, chain with `uppercase`.
- `left n "leftborder" "rightborder"`: Renders a textual value in a block of width `n`, aligned to the left, with an optional left and right border. Has no effect on other values. This can be used to align material in tables. Widths are positive integers indicating the number of characters. Borders are strings inside double quotes; literal `"` and `\` characters must be backslash-escaped.
- `right n "leftborder" "rightborder"`: Renders a textual value in a block of width `n`, aligned to the right, and has no effect on other values.
- `center n "leftborder" "rightborder"`: Renders a textual value in a block of width `n`, aligned to the center, and has no effect on other values.

Synopsis

- renderTemplate :: (TemplateTarget a, ToContext a b) => Template a -> b -> Doc a
- compileTemplate :: (TemplateMonad m, TemplateTarget a) => FilePath -> Text -> m (Either String (Template a))
- compileTemplateFile :: TemplateTarget a => FilePath -> IO (Either String (Template a))
- applyTemplate :: (TemplateMonad m, TemplateTarget a, ToContext a b) => FilePath -> Text -> b -> m (Either String (Doc a))
- class Monad m => TemplateMonad (m :: Type -> Type) where
  - getPartial :: FilePath -> m Text
- type TemplateTarget a = (HasChars a, ToText a, FromText a)
- newtype Context a = Context {
  - unContext :: Map Text (Val a)
  }
- data Val a
  - = SimpleVal (Doc a)
  - | ListVal [Val a]
  - | MapVal (Context a)
  - | BoolVal Bool
  - | NullVal
- class ToContext a b where
  - toContext :: b -> Context a
  - toVal :: b -> Val a
- class FromContext a b where
  - fromVal :: Val a -> Maybe b
  - lookupContext :: Text -> Context a -> Maybe b
- data Template a
- data Doc a
  - = Text Int a
  - | Block Int [Attributed a]
  - | VFill Int a
  - | CookedText Int (Attributed a)
  - | Prefixed Text (Doc a)
  - | BeforeNonBlank (Doc a)
  - | Flush (Doc a)
  - | BreakingSpace
  - | AfterBreak Text
  - | CarriageReturn
  - | NewLine
  - | BlankLines Int
  - | Concat (Doc a) (Doc a)
  - | Styled StyleReq (Doc a)
  - | Linked Text (Doc a)
  - | Empty

# Documentation

renderTemplate :: (TemplateTarget a, ToContext a b) => Template a -> b -> Doc a Source #

Render a compiled template in a "context" which provides values for the template's variables.

compileTemplate :: (TemplateMonad m, TemplateTarget a) => FilePath -> Text -> m (Either String (Template a)) Source #

Compile a template. The FilePath parameter is used to determine a default path and extension for partials and may be left empty if partials are not used.

compileTemplateFile :: TemplateTarget a => FilePath -> IO (Either String (Template a)) Source #

Compile a template from a file. IO errors will be raised as exceptions; template parsing errors result in Left return values.

applyTemplate :: (TemplateMonad m, TemplateTarget a, ToContext a b) => FilePath -> Text -> b -> m (Either String (Doc a)) Source #

Compile a template and apply it to a context. This is just a convenience function composing `compileTemplate` and `renderTemplate`. If a template will be rendered more than once in the same process, compile it separately for better performance.

class Monad m => TemplateMonad (m :: Type -> Type) where Source #

A `TemplateMonad` defines a function to retrieve a partial (from the file system, from a database, or using a default value).

Methods

getPartial :: FilePath -> m Text Source #

#### Instances

Instances details

TemplateMonad Identity Source # |
Instance details Defined in Text.DocTemplates.Internal Methods getPartial :: FilePath -> Identity Text Source #
TemplateMonad IO Source # |
Instance details Defined in Text.DocTemplates.Internal Methods getPartial :: FilePath -> IO Text Source #

type TemplateTarget a = (HasChars a, ToText a, FromText a) Source #

newtype Context a Source #

A `Context` defines values for template's variables.

Constructors

Context |

Fields

- unContext :: Map Text (Val a)

#### Instances

Instances details

Functor Context Source # |
Instance details Defined in Text.DocTemplates.Internal Methods fmap :: (a -> b) -> Context a -> Context b Source # (<$) :: a -> Context b -> Context a Source #
Foldable Context Source # |

Instance details

Defined in Text.DocTemplates.Internal

Methods

fold :: Monoid m => Context m -> m Source #

foldMap :: Monoid m => (a -> m) -> Context a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Context a -> m Source #

foldr :: (a -> b -> b) -> b -> Context a -> b Source #

foldr' :: (a -> b -> b) -> b -> Context a -> b Source #

foldl :: (b -> a -> b) -> b -> Context a -> b Source #

foldl' :: (b -> a -> b) -> b -> Context a -> b Source #

foldr1 :: (a -> a -> a) -> Context a -> a Source #

foldl1 :: (a -> a -> a) -> Context a -> a Source #

toList :: Context a -> [a] Source #

null :: Context a -> Bool Source #

length :: Context a -> Int Source #

elem :: Eq a => a -> Context a -> Bool Source #

maximum :: Ord a => Context a -> a Source #

minimum :: Ord a => Context a -> a Source #

sum :: Num a => Context a -> a Source #

product :: Num a => Context a -> a Source #

Traversable Context Source # |
Instance details Defined in Text.DocTemplates.Internal Methods traverse :: Applicative f => (a -> f b) -> Context a -> f (Context b) Source # sequenceA :: Applicative f => Context (f a) -> f (Context a) Source # mapM :: Monad m => (a -> m b) -> Context a -> m (Context b) Source # sequence :: Monad m => Context (m a) -> m (Context a) Source #
ToContext a (Context a) Source # |
Instance details Defined in Text.DocTemplates.Internal Methods toContext :: Context a -> Context a Source # toVal :: Context a -> Val a Source #
TemplateTarget a => FromJSON (Context a) Source # |
Instance details Defined in Text.DocTemplates.Internal Methods parseJSON :: Value -> Parser (Context a) Source # parseJSONList :: Value -> Parser [Context a] Source # omittedField :: Maybe (Context a) Source #
TemplateTarget a => ToJSON (Context a) Source # |
Instance details Defined in Text.DocTemplates.Internal Methods toJSON :: Context a -> Value Source # toEncoding :: Context a -> Encoding Source # toJSONList :: [Context a] -> Value Source # toEncodingList :: [Context a] -> Encoding Source # omitField :: Context a -> Bool Source #
Monoid (Context a) Source # |
Instance details Defined in Text.DocTemplates.Internal Methods mempty :: Context a Source # mappend :: Context a -> Context a -> Context a Source # mconcat :: [Context a] -> Context a Source #
Semigroup (Context a) Source # |
Instance details Defined in Text.DocTemplates.Internal Methods (<>) :: Context a -> Context a -> Context a Source # sconcat :: NonEmpty (Context a) -> Context a Source # stimes :: Integral b => b -> Context a -> Context a Source #
Data a => Data (Context a) Source # |

Instance details

Defined in Text.DocTemplates.Internal

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Context a -> c (Context a) Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Context a) Source #

toConstr :: Context a -> Constr Source #

dataTypeOf :: Context a -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Context a)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Context a)) Source #

gmapT :: (forall b. Data b => b -> b) -> Context a -> Context a Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Context a -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Context a -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Context a -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Context a -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Context a -> m (Context a) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Context a -> m (Context a) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Context a -> m (Context a) Source #

Show a => Show (Context a) Source # |
Instance details Defined in Text.DocTemplates.Internal Methods showsPrec :: Int -> Context a -> ShowS Source # show :: Context a -> String Source # showList :: [Context a] -> ShowS Source #

data Val a Source #

A variable value.

Constructors

SimpleVal (Doc a) |
ListVal [Val a] |
MapVal (Context a) |
BoolVal Bool |
NullVal |

#### Instances

Instances details

Functor Val Source # |
Instance details Defined in Text.DocTemplates.Internal Methods fmap :: (a -> b) -> Val a -> Val b Source # (<$) :: a -> Val b -> Val a Source #
Foldable Val Source # |

Instance details

Defined in Text.DocTemplates.Internal

Methods

fold :: Monoid m => Val m -> m Source #

foldMap :: Monoid m => (a -> m) -> Val a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Val a -> m Source #

foldr :: (a -> b -> b) -> b -> Val a -> b Source #

foldr' :: (a -> b -> b) -> b -> Val a -> b Source #

foldl :: (b -> a -> b) -> b -> Val a -> b Source #

foldl' :: (b -> a -> b) -> b -> Val a -> b Source #

foldr1 :: (a -> a -> a) -> Val a -> a Source #

foldl1 :: (a -> a -> a) -> Val a -> a Source #

toList :: Val a -> [a] Source #

null :: Val a -> Bool Source #

length :: Val a -> Int Source #

elem :: Eq a => a -> Val a -> Bool Source #

maximum :: Ord a => Val a -> a Source #

minimum :: Ord a => Val a -> a Source #

sum :: Num a => Val a -> a Source #

product :: Num a => Val a -> a Source #

Traversable Val Source # |
Instance details Defined in Text.DocTemplates.Internal Methods traverse :: Applicative f => (a -> f b) -> Val a -> f (Val b) Source # sequenceA :: Applicative f => Val (f a) -> f (Val a) Source # mapM :: Monad m => (a -> m b) -> Val a -> m (Val b) Source # sequence :: Monad m => Val (m a) -> m (Val a) Source #
TemplateTarget a => FromContext a (Val a) Source # |
Instance details Defined in Text.DocTemplates.Internal Methods fromVal :: Val a -> Maybe (Val a) Source # lookupContext :: Text -> Context a -> Maybe (Val a) Source #
ToContext a (Val a) Source # |
Instance details Defined in Text.DocTemplates.Internal Methods toContext :: Val a -> Context a Source # toVal :: Val a -> Val a Source #
TemplateTarget a => FromJSON (Val a) Source # |
Instance details Defined in Text.DocTemplates.Internal Methods parseJSON :: Value -> Parser (Val a) Source # parseJSONList :: Value -> Parser [Val a] Source # omittedField :: Maybe (Val a) Source #
TemplateTarget a => ToJSON (Val a) Source # |
Instance details Defined in Text.DocTemplates.Internal Methods toJSON :: Val a -> Value Source # toEncoding :: Val a -> Encoding Source # toJSONList :: [Val a] -> Value Source # toEncodingList :: [Val a] -> Encoding Source # omitField :: Val a -> Bool Source #
Data a => Data (Val a) Source # |

Instance details

Defined in Text.DocTemplates.Internal

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Val a -> c (Val a) Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Val a) Source #

toConstr :: Val a -> Constr Source #

dataTypeOf :: Val a -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Val a)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Val a)) Source #

gmapT :: (forall b. Data b => b -> b) -> Val a -> Val a Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Val a -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Val a -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Val a -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Val a -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Val a -> m (Val a) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Val a -> m (Val a) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Val a -> m (Val a) Source #

Show a => Show (Val a) Source # |
Instance details Defined in Text.DocTemplates.Internal Methods showsPrec :: Int -> Val a -> ShowS Source # show :: Val a -> String Source # showList :: [Val a] -> ShowS Source #

class ToContext a b where Source #

The `ToContext` class provides automatic conversion to a `Context` or `Val`.

Minimal complete definition

toVal

Methods

toContext :: b -> Context a Source #

toVal :: b -> Val a Source #

#### Instances

Instances details

TemplateTarget a => ToContext a Value Source # |
Instance details Defined in Text.DocTemplates.Internal Methods toContext :: Value -> Context a Source # toVal :: Value -> Val a Source #
TemplateTarget a => ToContext a Bool Source # |
Instance details Defined in Text.DocTemplates.Internal Methods toContext :: Bool -> Context a Source # toVal :: Bool -> Val a Source #
TemplateTarget a => ToContext a a Source # |
Instance details Defined in Text.DocTemplates.Internal Methods toContext :: a -> Context a Source # toVal :: a -> Val a Source #
ToContext a a => ToContext a (Doc a) Source # |
Instance details Defined in Text.DocTemplates.Internal Methods toContext :: Doc a -> Context a Source # toVal :: Doc a -> Val a Source #
ToContext a (Context a) Source # |
Instance details Defined in Text.DocTemplates.Internal Methods toContext :: Context a -> Context a Source # toVal :: Context a -> Val a Source #
ToContext a (Val a) Source # |
Instance details Defined in Text.DocTemplates.Internal Methods toContext :: Val a -> Context a Source # toVal :: Val a -> Val a Source #
ToContext a b => ToContext a [b] Source # |
Instance details Defined in Text.DocTemplates.Internal Methods toContext :: [b] -> Context a Source # toVal :: [b] -> Val a Source #
ToContext a b => ToContext a (Map Text b) Source # |
Instance details Defined in Text.DocTemplates.Internal Methods toContext :: Map Text b -> Context a Source # toVal :: Map Text b -> Val a Source #
TemplateTarget [a] => ToContext [a] [a] Source # |
Instance details Defined in Text.DocTemplates.Internal Methods toContext :: [a] -> Context [a] Source # toVal :: [a] -> Val [a] Source #

class FromContext a b where Source #

The `FromContext` class provides functions for extracting values from `Val` and `Context`.

Minimal complete definition

fromVal

Methods

fromVal :: Val a -> Maybe b Source #

lookupContext :: Text -> Context a -> Maybe b Source #

#### Instances

Instances details

TemplateTarget a => FromContext a a Source # |
Instance details Defined in Text.DocTemplates.Internal Methods fromVal :: Val a -> Maybe a Source # lookupContext :: Text -> Context a -> Maybe a Source #
TemplateTarget a => FromContext a (Doc a) Source # |
Instance details Defined in Text.DocTemplates.Internal Methods fromVal :: Val a -> Maybe (Doc a) Source # lookupContext :: Text -> Context a -> Maybe (Doc a) Source #
TemplateTarget a => FromContext a (Val a) Source # |
Instance details Defined in Text.DocTemplates.Internal Methods fromVal :: Val a -> Maybe (Val a) Source # lookupContext :: Text -> Context a -> Maybe (Val a) Source #
FromContext a b => FromContext a [b] Source # |
Instance details Defined in Text.DocTemplates.Internal Methods fromVal :: Val a -> Maybe [b] Source # lookupContext :: Text -> Context a -> Maybe [b] Source #
TemplateTarget [a] => FromContext [a] [a] Source # |
Instance details Defined in Text.DocTemplates.Internal Methods fromVal :: Val [a] -> Maybe [a] Source # lookupContext :: Text -> Context [a] -> Maybe [a] Source #

data Template a Source #

A template.

#### Instances

Instances details

Functor Template Source # |
Instance details Defined in Text.DocTemplates.Internal Methods fmap :: (a -> b) -> Template a -> Template b Source # (<$) :: a -> Template b -> Template a Source #
Foldable Template Source # |

Instance details

Defined in Text.DocTemplates.Internal

Methods

fold :: Monoid m => Template m -> m Source #

foldMap :: Monoid m => (a -> m) -> Template a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Template a -> m Source #

foldr :: (a -> b -> b) -> b -> Template a -> b Source #

foldr' :: (a -> b -> b) -> b -> Template a -> b Source #

foldl :: (b -> a -> b) -> b -> Template a -> b Source #

foldl' :: (b -> a -> b) -> b -> Template a -> b Source #

foldr1 :: (a -> a -> a) -> Template a -> a Source #

foldl1 :: (a -> a -> a) -> Template a -> a Source #

toList :: Template a -> [a] Source #

null :: Template a -> Bool Source #

length :: Template a -> Int Source #

elem :: Eq a => a -> Template a -> Bool Source #

maximum :: Ord a => Template a -> a Source #

minimum :: Ord a => Template a -> a Source #

sum :: Num a => Template a -> a Source #

product :: Num a => Template a -> a Source #

Traversable Template Source # |
Instance details Defined in Text.DocTemplates.Internal Methods traverse :: Applicative f => (a -> f b) -> Template a -> f (Template b) Source # sequenceA :: Applicative f => Template (f a) -> f (Template a) Source # mapM :: Monad m => (a -> m b) -> Template a -> m (Template b) Source # sequence :: Monad m => Template (m a) -> m (Template a) Source #
Semigroup a => Monoid (Template a) Source # |
Instance details Defined in Text.DocTemplates.Internal Methods mempty :: Template a Source # mappend :: Template a -> Template a -> Template a Source # mconcat :: [Template a] -> Template a Source #
Semigroup a => Semigroup (Template a) Source # |
Instance details Defined in Text.DocTemplates.Internal Methods (<>) :: Template a -> Template a -> Template a Source # sconcat :: NonEmpty (Template a) -> Template a Source # stimes :: Integral b => b -> Template a -> Template a Source #
Data a => Data (Template a) Source # |

Instance details

Defined in Text.DocTemplates.Internal

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Template a -> c (Template a) Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Template a) Source #

toConstr :: Template a -> Constr Source #

dataTypeOf :: Template a -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Template a)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Template a)) Source #

gmapT :: (forall b. Data b => b -> b) -> Template a -> Template a Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Template a -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Template a -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Template a -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Template a -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Template a -> m (Template a) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Template a -> m (Template a) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Template a -> m (Template a) Source #

Generic (Template a) Source # |

Instance details

Defined in Text.DocTemplates.Internal

Associated Types

type Rep (Template a) |

Instance details

Defined in Text.DocTemplates.Internal

type Rep (Template a) = D1 ('MetaData "Template" "Text.DocTemplates.Internal" "doctemplates-0.11.0.1-D1ix9osNqlP9wO3nyCLxCL" 'False) (((C1 ('MetaCons "Interpolate" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Variable)) :+: C1 ('MetaCons "Conditional" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Variable) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Template a)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Template a))))) :+: (C1 ('MetaCons "Iterate" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Variable) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Template a)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Template a)))) :+: C1 ('MetaCons "Nested" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Template a))))) :+: ((C1 ('MetaCons "Partial" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Pipe]) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Template a))) :+: C1 ('MetaCons "Literal" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Doc a)))) :+: (C1 ('MetaCons "Concat" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Template a)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Template a))) :+: C1 ('MetaCons "Empty" 'PrefixI 'False) (U1 :: Type -> Type))))

Methods

from :: Template a -> Rep (Template a) x Source #

to :: Rep (Template a) x -> Template a Source #

Read a => Read (Template a) Source # |
Instance details Defined in Text.DocTemplates.Internal Methods readsPrec :: Int -> ReadS (Template a) Source # readList :: ReadS [Template a] Source # readPrec :: ReadPrec (Template a) Source # readListPrec :: ReadPrec [Template a] Source #
Show a => Show (Template a) Source # |
Instance details Defined in Text.DocTemplates.Internal Methods showsPrec :: Int -> Template a -> ShowS Source # show :: Template a -> String Source # showList :: [Template a] -> ShowS Source #
Eq a => Eq (Template a) Source # |
Instance details Defined in Text.DocTemplates.Internal Methods (==) :: Template a -> Template a -> Bool Source # (/=) :: Template a -> Template a -> Bool Source #
Ord a => Ord (Template a) Source # |

Instance details

Defined in Text.DocTemplates.Internal

Methods

compare :: Template a -> Template a -> Ordering Source #

(<) :: Template a -> Template a -> Bool Source #

(<=) :: Template a -> Template a -> Bool Source #

(>) :: Template a -> Template a -> Bool Source #

(>=) :: Template a -> Template a -> Bool Source #

max :: Template a -> Template a -> Template a Source #

min :: Template a -> Template a -> Template a Source #

type Rep (Template a) Source # |

Instance details

Defined in Text.DocTemplates.Internal

type Rep (Template a) = D1 ('MetaData "Template" "Text.DocTemplates.Internal" "doctemplates-0.11.0.1-D1ix9osNqlP9wO3nyCLxCL" 'False) (((C1 ('MetaCons "Interpolate" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Variable)) :+: C1 ('MetaCons "Conditional" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Variable) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Template a)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Template a))))) :+: (C1 ('MetaCons "Iterate" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Variable) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Template a)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Template a)))) :+: C1 ('MetaCons "Nested" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Template a))))) :+: ((C1 ('MetaCons "Partial" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Pipe]) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Template a))) :+: C1 ('MetaCons "Literal" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Doc a)))) :+: (C1 ('MetaCons "Concat" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Template a)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Template a))) :+: C1 ('MetaCons "Empty" 'PrefixI 'False) (U1 :: Type -> Type))))

data Doc a Source #

Document, including structure relevant for layout.

Constructors

Text Int a | Text with specified width.
Block Int [Attributed a] | A block with a width and lines.
VFill Int a | A vertically expandable block; when concatenated with a block, expands to height of block, with each line containing the specified text.
CookedText Int (Attributed a) | Text which doesn't need further cooking
Prefixed Text (Doc a) | Doc with each line prefixed with text. Note that trailing blanks are omitted from the prefix when the line after it is empty.
BeforeNonBlank (Doc a) | Doc that renders only before nonblank.
Flush (Doc a) | Doc laid out flush to left margin.
BreakingSpace | A space or line break, in context.
AfterBreak Text | Text printed only at start of line.
CarriageReturn | Newline unless we're at start of line.
NewLine | newline.
BlankLines Int | Ensure a number of blank lines.
Concat (Doc a) (Doc a) | Two documents concatenated.
Styled StyleReq (Doc a) |
Linked Text (Doc a) | A hyperlink
Empty |

#### Instances

Instances details

Functor Doc |
Instance details Defined in Text.DocLayout Methods fmap :: (a -> b) -> Doc a -> Doc b Source # (<$) :: a -> Doc b -> Doc a Source #
Foldable Doc |

Instance details

Defined in Text.DocLayout

Methods

fold :: Monoid m => Doc m -> m Source #

foldMap :: Monoid m => (a -> m) -> Doc a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Doc a -> m Source #

foldr :: (a -> b -> b) -> b -> Doc a -> b Source #

foldr' :: (a -> b -> b) -> b -> Doc a -> b Source #

foldl :: (b -> a -> b) -> b -> Doc a -> b Source #

foldl' :: (b -> a -> b) -> b -> Doc a -> b Source #

foldr1 :: (a -> a -> a) -> Doc a -> a Source #

foldl1 :: (a -> a -> a) -> Doc a -> a Source #

toList :: Doc a -> [a] Source #

null :: Doc a -> Bool Source #

length :: Doc a -> Int Source #

elem :: Eq a => a -> Doc a -> Bool Source #

maximum :: Ord a => Doc a -> a Source #

minimum :: Ord a => Doc a -> a Source #

sum :: Num a => Doc a -> a Source #

product :: Num a => Doc a -> a Source #

Traversable Doc |
Instance details Defined in Text.DocLayout Methods traverse :: Applicative f => (a -> f b) -> Doc a -> f (Doc b) Source # sequenceA :: Applicative f => Doc (f a) -> f (Doc a) Source # mapM :: Monad m => (a -> m b) -> Doc a -> m (Doc b) Source # sequence :: Monad m => Doc (m a) -> m (Doc a) Source #
TemplateTarget a => FromContext a (Doc a) Source # |
Instance details Defined in Text.DocTemplates.Internal Methods fromVal :: Val a -> Maybe (Doc a) Source # lookupContext :: Text -> Context a -> Maybe (Doc a) Source #
ToContext a a => ToContext a (Doc a) Source # |
Instance details Defined in Text.DocTemplates.Internal Methods toContext :: Doc a -> Context a Source # toVal :: Doc a -> Val a Source #
Monoid (Doc a) |
Instance details Defined in Text.DocLayout Methods mempty :: Doc a Source # mappend :: Doc a -> Doc a -> Doc a Source # mconcat :: [Doc a] -> Doc a Source #
Semigroup (Doc a) |
Instance details Defined in Text.DocLayout Methods (<>) :: Doc a -> Doc a -> Doc a Source # sconcat :: NonEmpty (Doc a) -> Doc a Source # stimes :: Integral b => b -> Doc a -> Doc a Source #
Data a => Data (Doc a) |

Instance details

Defined in Text.DocLayout

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Doc a -> c (Doc a) Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Doc a) Source #

toConstr :: Doc a -> Constr Source #

dataTypeOf :: Doc a -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Doc a)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Doc a)) Source #

gmapT :: (forall b. Data b => b -> b) -> Doc a -> Doc a Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Doc a -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Doc a -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Doc a -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Doc a -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Doc a -> m (Doc a) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Doc a -> m (Doc a) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Doc a -> m (Doc a) Source #

HasChars a => IsString (Doc a) |
Instance details Defined in Text.DocLayout Methods fromString :: String -> Doc a Source #
Generic (Doc a) |

Instance details

Defined in Text.DocLayout

Associated Types

type Rep (Doc a) |

Instance details

Defined in Text.DocLayout

type Rep (Doc a) = D1 ('MetaData "Doc" "Text.DocLayout" "doclayout-0.5.0.1-7bIhr21VwqRJlmHSH0MkeX" 'False) ((((C1 ('MetaCons "Text" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)) :+: C1 ('MetaCons "Block" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Attributed a]))) :+: (C1 ('MetaCons "VFill" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)) :+: C1 ('MetaCons "CookedText" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Attributed a))))) :+: ((C1 ('MetaCons "Prefixed" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Doc a))) :+: C1 ('MetaCons "BeforeNonBlank" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Doc a)))) :+: (C1 ('MetaCons "Flush" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Doc a))) :+: C1 ('MetaCons "BreakingSpace" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: (((C1 ('MetaCons "AfterBreak" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)) :+: C1 ('MetaCons "CarriageReturn" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "NewLine" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "BlankLines" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))) :+: ((C1 ('MetaCons "Concat" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Doc a)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Doc a))) :+: C1 ('MetaCons "Styled" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 StyleReq) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Doc a)))) :+: (C1 ('MetaCons "Linked" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Doc a))) :+: C1 ('MetaCons "Empty" 'PrefixI 'False) (U1 :: Type -> Type)))))

Methods

from :: Doc a -> Rep (Doc a) x Source #

to :: Rep (Doc a) x -> Doc a Source #

Read a => Read (Doc a) |
Instance details Defined in Text.DocLayout Methods readsPrec :: Int -> ReadS (Doc a) Source # readList :: ReadS [Doc a] Source # readPrec :: ReadPrec (Doc a) Source # readListPrec :: ReadPrec [Doc a] Source #
Show a => Show (Doc a) |
Instance details Defined in Text.DocLayout Methods showsPrec :: Int -> Doc a -> ShowS Source # show :: Doc a -> String Source # showList :: [Doc a] -> ShowS Source #
Eq a => Eq (Doc a) |
Instance details Defined in Text.DocLayout Methods (==) :: Doc a -> Doc a -> Bool Source # (/=) :: Doc a -> Doc a -> Bool Source #
Ord a => Ord (Doc a) |
Instance details Defined in Text.DocLayout Methods compare :: Doc a -> Doc a -> Ordering Source # (<) :: Doc a -> Doc a -> Bool Source # (<=) :: Doc a -> Doc a -> Bool Source # (>) :: Doc a -> Doc a -> Bool Source # (>=) :: Doc a -> Doc a -> Bool Source # max :: Doc a -> Doc a -> Doc a Source # min :: Doc a -> Doc a -> Doc a Source #
type Rep (Doc a) |

Instance details

Defined in Text.DocLayout

type Rep (Doc a) = D1 ('MetaData "Doc" "Text.DocLayout" "doclayout-0.5.0.1-7bIhr21VwqRJlmHSH0MkeX" 'False) ((((C1 ('MetaCons "Text" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)) :+: C1 ('MetaCons "Block" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Attributed a]))) :+: (C1 ('MetaCons "VFill" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)) :+: C1 ('MetaCons "CookedText" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Attributed a))))) :+: ((C1 ('MetaCons "Prefixed" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Doc a))) :+: C1 ('MetaCons "BeforeNonBlank" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Doc a)))) :+: (C1 ('MetaCons "Flush" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Doc a))) :+: C1 ('MetaCons "BreakingSpace" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: (((C1 ('MetaCons "AfterBreak" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)) :+: C1 ('MetaCons "CarriageReturn" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "NewLine" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "BlankLines" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))) :+: ((C1 ('MetaCons "Concat" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Doc a)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Doc a))) :+: C1 ('MetaCons "Styled" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 StyleReq) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Doc a)))) :+: (C1 ('MetaCons "Linked" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Doc a))) :+: C1 ('MetaCons "Empty" 'PrefixI 'False) (U1 :: Type -> Type)))))