    {-# LANGUAGE CPP #-}
    {-# LANGUAGE ConstraintKinds #-}
    {-# LANGUAGE GeneralizedNewtypeDeriving #-}
    {-# LANGUAGE MultiParamTypeClasses #-}
    {-# LANGUAGE FlexibleContexts #-}
    {-# LANGUAGE FlexibleInstances #-}
    {-# LANGUAGE OverloadedStrings #-}
    {-# LANGUAGE ScopedTypeVariables #-}
    {-# LANGUAGE DeriveDataTypeable #-}
    {-# LANGUAGE DeriveGeneric #-}
    {-# LANGUAGE DeriveTraversable #-}

    {- |
       Module      : Text.DocTemplates.Internal
       Copyright   : Copyright (C) 2009-2019 John MacFarlane
       License     : BSD3

       Maintainer  : John MacFarlane <jgm@berkeley.edu>
       Stability   : alpha
       Portability : portable
    -}

    module Text.DocTemplates.Internal
          ( renderTemplate
          , TemplateMonad(..)
          , Context(..)
          , Val(..)
          , ToContext(..)
          , FromContext(..)
          , TemplateTarget
          , Template(..)
          , Variable(..)
          , Pipe(..)
          , Alignment(..)
          , Border(..)
          ) where

    import Data.Text.Conversions (FromText(..), ToText(..))
    import Data.Aeson (Value(..), ToJSON(..), FromJSON(..), Result(..), fromJSON)
    import Control.Monad.Identity
    import qualified Control.Monad.State.Strict as S
    import Data.Char (chr, ord)
    import Data.Maybe (fromMaybe)
    import qualified Data.Text.Read as T
    import qualified Data.Text as T
    import qualified Data.Text.IO as TIO
    import Text.DocLayout (Doc, HasChars)
    import qualified Text.DocLayout as DL
    import Data.String (IsString(..))
    import Data.Data (Data)
    import Data.Typeable (Typeable)
    import GHC.Generics (Generic)
    import Data.Text (Text)
    import qualified Data.Map as M
    import qualified Data.Vector as V
    import Data.Scientific (floatingOrInteger)
    import Data.List (intersperse)
    #if MIN_VERSION_base(4,11,0)
    #else
    import Data.Semigroup
    #endif

    -- | A template.
    data Template a =
           Interpolate Variable
         | Conditional Variable (Template a) (Template a)
         | Iterate Variable (Template a) (Template a)
         | Nested (Template a)
         | Partial [Pipe] (Template a)
         | Literal (Doc a)
         | Concat (Template a) (Template a)
         | Empty
         deriving (Int -> Template a -> ShowS
    [Template a] -> ShowS
    Template a -> String
    (Int -> Template a -> ShowS)
    -> (Template a -> String)
    -> ([Template a] -> ShowS)
    -> Show (Template a)
    forall a. Show a => Int -> Template a -> ShowS
    forall a. Show a => [Template a] -> ShowS
    forall a. Show a => Template a -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: forall a. Show a => Int -> Template a -> ShowS
    showsPrec :: Int -> Template a -> ShowS
    $cshow :: forall a. Show a => Template a -> String
    show :: Template a -> String
    $cshowList :: forall a. Show a => [Template a] -> ShowS
    showList :: [Template a] -> ShowS
    Show, ReadPrec [Template a]
    ReadPrec (Template a)
    Int -> ReadS (Template a)
    ReadS [Template a]
    (Int -> ReadS (Template a))
    -> ReadS [Template a]
    -> ReadPrec (Template a)
    -> ReadPrec [Template a]
    -> Read (Template a)
    forall a. Read a => ReadPrec [Template a]
    forall a. Read a => ReadPrec (Template a)
    forall a. Read a => Int -> ReadS (Template a)
    forall a. Read a => ReadS [Template a]
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: forall a. Read a => Int -> ReadS (Template a)
    readsPrec :: Int -> ReadS (Template a)
    $creadList :: forall a. Read a => ReadS [Template a]
    readList :: ReadS [Template a]
    $creadPrec :: forall a. Read a => ReadPrec (Template a)
    readPrec :: ReadPrec (Template a)
    $creadListPrec :: forall a. Read a => ReadPrec [Template a]
    readListPrec :: ReadPrec [Template a]
    Read, Typeable (Template a)
    Typeable (Template a) =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> Template a -> c (Template a))
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c (Template a))
    -> (Template a -> Constr)
    -> (Template a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c (Template a)))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e))
        -> Maybe (c (Template a)))
    -> ((forall b. Data b => b -> b) -> Template a -> Template a)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> Template a -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> Template a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> Template a -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> Template a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> Template a -> m (Template a))
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Template a -> m (Template a))
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Template a -> m (Template a))
    -> Data (Template a)
    Template a -> Constr
    Template a -> DataType
    (forall b. Data b => b -> b) -> Template a -> Template a
    forall a. Data a => Typeable (Template a)
    forall a. Data a => Template a -> Constr
    forall a. Data a => Template a -> DataType
    forall a.
    Data a =>
    (forall b. Data b => b -> b) -> Template a -> Template a
    forall a u.
    Data a =>
    Int -> (forall d. Data d => d -> u) -> Template a -> u
    forall a u.
    Data a =>
    (forall d. Data d => d -> u) -> Template a -> [u]
    forall a r r'.
    Data a =>
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Template a -> r
    forall a r r'.
    Data a =>
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Template a -> r
    forall a (m :: * -> *).
    (Data a, Monad m) =>
    (forall d. Data d => d -> m d) -> Template a -> m (Template a)
    forall a (m :: * -> *).
    (Data a, MonadPlus m) =>
    (forall d. Data d => d -> m d) -> Template a -> m (Template a)
    forall a (c :: * -> *).
    Data a =>
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Template a)
    forall a (c :: * -> *).
    Data a =>
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Template a -> c (Template a)
    forall a (t :: * -> *) (c :: * -> *).
    (Data a, Typeable t) =>
    (forall d. Data d => c (t d)) -> Maybe (c (Template a))
    forall a (t :: * -> * -> *) (c :: * -> *).
    (Data a, Typeable t) =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (Template a))
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> Template a -> u
    forall u. (forall d. Data d => d -> u) -> Template a -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Template a -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Template a -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Template a -> m (Template a)
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Template a -> m (Template a)
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Template a)
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Template a -> c (Template a)
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Template a))
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (Template a))
    $cgfoldl :: forall a (c :: * -> *).
    Data a =>
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Template a -> c (Template a)
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Template a -> c (Template a)
    $cgunfold :: forall a (c :: * -> *).
    Data a =>
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Template a)
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Template a)
    $ctoConstr :: forall a. Data a => Template a -> Constr
    toConstr :: Template a -> Constr
    $cdataTypeOf :: forall a. Data a => Template a -> DataType
    dataTypeOf :: Template a -> DataType
    $cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
    (Data a, Typeable t) =>
    (forall d. Data d => c (t d)) -> Maybe (c (Template a))
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Template a))
    $cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
    (Data a, Typeable t) =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (Template a))
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (Template a))
    $cgmapT :: forall a.
    Data a =>
    (forall b. Data b => b -> b) -> Template a -> Template a
    gmapT :: (forall b. Data b => b -> b) -> Template a -> Template a
    $cgmapQl :: forall a r r'.
    Data a =>
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Template a -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Template a -> r
    $cgmapQr :: forall a r r'.
    Data a =>
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Template a -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Template a -> r
    $cgmapQ :: forall a u.
    Data a =>
    (forall d. Data d => d -> u) -> Template a -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> Template a -> [u]
    $cgmapQi :: forall a u.
    Data a =>
    Int -> (forall d. Data d => d -> u) -> Template a -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Template a -> u
    $cgmapM :: forall a (m :: * -> *).
    (Data a, Monad m) =>
    (forall d. Data d => d -> m d) -> Template a -> m (Template a)
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Template a -> m (Template a)
    $cgmapMp :: forall a (m :: * -> *).
    (Data a, MonadPlus m) =>
    (forall d. Data d => d -> m d) -> Template a -> m (Template a)
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Template a -> m (Template a)
    $cgmapMo :: forall a (m :: * -> *).
    (Data a, MonadPlus m) =>
    (forall d. Data d => d -> m d) -> Template a -> m (Template a)
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Template a -> m (Template a)
    Data, Typeable, (forall x. Template a -> Rep (Template a) x)
    -> (forall x. Rep (Template a) x -> Template a)
    -> Generic (Template a)
    forall x. Rep (Template a) x -> Template a
    forall x. Template a -> Rep (Template a) x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    forall a x. Rep (Template a) x -> Template a
    forall a x. Template a -> Rep (Template a) x
    $cfrom :: forall a x. Template a -> Rep (Template a) x
    from :: forall x. Template a -> Rep (Template a) x
    $cto :: forall a x. Rep (Template a) x -> Template a
    to :: forall x. Rep (Template a) x -> Template a
    Generic, Template a -> Template a -> Bool
    (Template a -> Template a -> Bool)
    -> (Template a -> Template a -> Bool) -> Eq (Template a)
    forall a. Eq a => Template a -> Template a -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: forall a. Eq a => Template a -> Template a -> Bool
    == :: Template a -> Template a -> Bool
    $c/= :: forall a. Eq a => Template a -> Template a -> Bool
    /= :: Template a -> Template a -> Bool
    Eq, Eq (Template a)
    Eq (Template a) =>
    (Template a -> Template a -> Ordering)
    -> (Template a -> Template a -> Bool)
    -> (Template a -> Template a -> Bool)
    -> (Template a -> Template a -> Bool)
    -> (Template a -> Template a -> Bool)
    -> (Template a -> Template a -> Template a)
    -> (Template a -> Template a -> Template a)
    -> Ord (Template a)
    Template a -> Template a -> Bool
    Template a -> Template a -> Ordering
    Template a -> Template a -> Template a
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    forall a. Ord a => Eq (Template a)
    forall a. Ord a => Template a -> Template a -> Bool
    forall a. Ord a => Template a -> Template a -> Ordering
    forall a. Ord a => Template a -> Template a -> Template a
    $ccompare :: forall a. Ord a => Template a -> Template a -> Ordering
    compare :: Template a -> Template a -> Ordering
    $c< :: forall a. Ord a => Template a -> Template a -> Bool
    < :: Template a -> Template a -> Bool
    $c<= :: forall a. Ord a => Template a -> Template a -> Bool
    <= :: Template a -> Template a -> Bool
    $c> :: forall a. Ord a => Template a -> Template a -> Bool
    > :: Template a -> Template a -> Bool
    $c>= :: forall a. Ord a => Template a -> Template a -> Bool
    >= :: Template a -> Template a -> Bool
    $cmax :: forall a. Ord a => Template a -> Template a -> Template a
    max :: Template a -> Template a -> Template a
    $cmin :: forall a. Ord a => Template a -> Template a -> Template a
    min :: Template a -> Template a -> Template a
    Ord,
                   (forall m. Monoid m => Template m -> m)
    -> (forall m a. Monoid m => (a -> m) -> Template a -> m)
    -> (forall m a. Monoid m => (a -> m) -> Template a -> m)
    -> (forall a b. (a -> b -> b) -> b -> Template a -> b)
    -> (forall a b. (a -> b -> b) -> b -> Template a -> b)
    -> (forall b a. (b -> a -> b) -> b -> Template a -> b)
    -> (forall b a. (b -> a -> b) -> b -> Template a -> b)
    -> (forall a. (a -> a -> a) -> Template a -> a)
    -> (forall a. (a -> a -> a) -> Template a -> a)
    -> (forall a. Template a -> [a])
    -> (forall a. Template a -> Bool)
    -> (forall a. Template a -> Int)
    -> (forall a. Eq a => a -> Template a -> Bool)
    -> (forall a. Ord a => Template a -> a)
    -> (forall a. Ord a => Template a -> a)
    -> (forall a. Num a => Template a -> a)
    -> (forall a. Num a => Template a -> a)
    -> Foldable Template
    forall a. Eq a => a -> Template a -> Bool
    forall a. Num a => Template a -> a
    forall a. Ord a => Template a -> a
    forall m. Monoid m => Template m -> m
    forall a. Template a -> Bool
    forall a. Template a -> Int
    forall a. Template a -> [a]
    forall a. (a -> a -> a) -> Template a -> a
    forall m a. Monoid m => (a -> m) -> Template a -> m
    forall b a. (b -> a -> b) -> b -> Template a -> b
    forall a b. (a -> b -> b) -> b -> Template a -> b
    forall (t :: * -> *).
    (forall m. Monoid m => t m -> m)
    -> (forall m a. Monoid m => (a -> m) -> t a -> m)
    -> (forall m a. Monoid m => (a -> m) -> t a -> m)
    -> (forall a b. (a -> b -> b) -> b -> t a -> b)
    -> (forall a b. (a -> b -> b) -> b -> t a -> b)
    -> (forall b a. (b -> a -> b) -> b -> t a -> b)
    -> (forall b a. (b -> a -> b) -> b -> t a -> b)
    -> (forall a. (a -> a -> a) -> t a -> a)
    -> (forall a. (a -> a -> a) -> t a -> a)
    -> (forall a. t a -> [a])
    -> (forall a. t a -> Bool)
    -> (forall a. t a -> Int)
    -> (forall a. Eq a => a -> t a -> Bool)
    -> (forall a. Ord a => t a -> a)
    -> (forall a. Ord a => t a -> a)
    -> (forall a. Num a => t a -> a)
    -> (forall a. Num a => t a -> a)
    -> Foldable t
    $cfold :: forall m. Monoid m => Template m -> m
    fold :: forall m. Monoid m => Template m -> m
    $cfoldMap :: forall m a. Monoid m => (a -> m) -> Template a -> m
    foldMap :: forall m a. Monoid m => (a -> m) -> Template a -> m
    $cfoldMap' :: forall m a. Monoid m => (a -> m) -> Template a -> m
    foldMap' :: forall m a. Monoid m => (a -> m) -> Template a -> m
    $cfoldr :: forall a b. (a -> b -> b) -> b -> Template a -> b
    foldr :: forall a b. (a -> b -> b) -> b -> Template a -> b
    $cfoldr' :: forall a b. (a -> b -> b) -> b -> Template a -> b
    foldr' :: forall a b. (a -> b -> b) -> b -> Template a -> b
    $cfoldl :: forall b a. (b -> a -> b) -> b -> Template a -> b
    foldl :: forall b a. (b -> a -> b) -> b -> Template a -> b
    $cfoldl' :: forall b a. (b -> a -> b) -> b -> Template a -> b
    foldl' :: forall b a. (b -> a -> b) -> b -> Template a -> b
    $cfoldr1 :: forall a. (a -> a -> a) -> Template a -> a
    foldr1 :: forall a. (a -> a -> a) -> Template a -> a
    $cfoldl1 :: forall a. (a -> a -> a) -> Template a -> a
    foldl1 :: forall a. (a -> a -> a) -> Template a -> a
    $ctoList :: forall a. Template a -> [a]
    toList :: forall a. Template a -> [a]
    $cnull :: forall a. Template a -> Bool
    null :: forall a. Template a -> Bool
    $clength :: forall a. Template a -> Int
    length :: forall a. Template a -> Int
    $celem :: forall a. Eq a => a -> Template a -> Bool
    elem :: forall a. Eq a => a -> Template a -> Bool
    $cmaximum :: forall a. Ord a => Template a -> a
    maximum :: forall a. Ord a => Template a -> a
    $cminimum :: forall a. Ord a => Template a -> a
    minimum :: forall a. Ord a => Template a -> a
    $csum :: forall a. Num a => Template a -> a
    sum :: forall a. Num a => Template a -> a
    $cproduct :: forall a. Num a => Template a -> a
    product :: forall a. Num a => Template a -> a
    Foldable, Functor Template
    Foldable Template
    (Functor Template, Foldable Template) =>
    (forall (f :: * -> *) a b.
     Applicative f =>
     (a -> f b) -> Template a -> f (Template b))
    -> (forall (f :: * -> *) a.
        Applicative f =>
        Template (f a) -> f (Template a))
    -> (forall (m :: * -> *) a b.
        Monad m =>
        (a -> m b) -> Template a -> m (Template b))
    -> (forall (m :: * -> *) a.
        Monad m =>
        Template (m a) -> m (Template a))
    -> Traversable Template
    forall (t :: * -> *).
    (Functor t, Foldable t) =>
    (forall (f :: * -> *) a b.
     Applicative f =>
     (a -> f b) -> t a -> f (t b))
    -> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
    -> (forall (m :: * -> *) a b.
        Monad m =>
        (a -> m b) -> t a -> m (t b))
    -> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
    -> Traversable t
    forall (m :: * -> *) a. Monad m => Template (m a) -> m (Template a)
    forall (f :: * -> *) a.
    Applicative f =>
    Template (f a) -> f (Template a)
    forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Template a -> m (Template b)
    forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> Template a -> f (Template b)
    $ctraverse :: forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> Template a -> f (Template b)
    traverse :: forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> Template a -> f (Template b)
    $csequenceA :: forall (f :: * -> *) a.
    Applicative f =>
    Template (f a) -> f (Template a)
    sequenceA :: forall (f :: * -> *) a.
    Applicative f =>
    Template (f a) -> f (Template a)
    $cmapM :: forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Template a -> m (Template b)
    mapM :: forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Template a -> m (Template b)
    $csequence :: forall (m :: * -> *) a. Monad m => Template (m a) -> m (Template a)
    sequence :: forall (m :: * -> *) a. Monad m => Template (m a) -> m (Template a)
    Traversable, (forall a b. (a -> b) -> Template a -> Template b)
    -> (forall a b. a -> Template b -> Template a) -> Functor Template
    forall a b. a -> Template b -> Template a
    forall a b. (a -> b) -> Template a -> Template b
    forall (f :: * -> *).
    (forall a b. (a -> b) -> f a -> f b)
    -> (forall a b. a -> f b -> f a) -> Functor f
    $cfmap :: forall a b. (a -> b) -> Template a -> Template b
    fmap :: forall a b. (a -> b) -> Template a -> Template b
    $c<$ :: forall a b. a -> Template b -> Template a
    <$ :: forall a b. a -> Template b -> Template a
    Functor)

    instance Semigroup a => Semigroup (Template a) where
      Template a
    x <> :: Template a -> Template a -> Template a
    <> Template a
    Empty = Template a
    x
      Template a
    Empty <> Template a
    x = Template a
    x
      Template a
    x <> Template a
    y = Template a -> Template a -> Template a
    forall a. Template a -> Template a -> Template a
    Concat Template a
    x Template a
    y

    instance Semigroup a => Monoid (Template a) where
      mappend :: Template a -> Template a -> Template a
    mappend = Template a -> Template a -> Template a
    forall a. Semigroup a => a -> a -> a
    (<>)
      mempty :: Template a
    mempty = Template a
    forall a. Template a
    Empty

    data Pipe =
          ToPairs
        | ToUppercase
        | ToLowercase
        | ToLength
        | Reverse
        | FirstItem
        | LastItem
        | Rest
        | AllButLast
        | Chomp
        | ToAlpha
        | ToRoman
        | NoWrap
        | Block Alignment Int Border
        deriving (Int -> Pipe -> ShowS
    [Pipe] -> ShowS
    Pipe -> String
    (Int -> Pipe -> ShowS)
    -> (Pipe -> String) -> ([Pipe] -> ShowS) -> Show Pipe
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Pipe -> ShowS
    showsPrec :: Int -> Pipe -> ShowS
    $cshow :: Pipe -> String
    show :: Pipe -> String
    $cshowList :: [Pipe] -> ShowS
    showList :: [Pipe] -> ShowS
    Show, ReadPrec [Pipe]
    ReadPrec Pipe
    Int -> ReadS Pipe
    ReadS [Pipe]
    (Int -> ReadS Pipe)
    -> ReadS [Pipe] -> ReadPrec Pipe -> ReadPrec [Pipe] -> Read Pipe
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS Pipe
    readsPrec :: Int -> ReadS Pipe
    $creadList :: ReadS [Pipe]
    readList :: ReadS [Pipe]
    $creadPrec :: ReadPrec Pipe
    readPrec :: ReadPrec Pipe
    $creadListPrec :: ReadPrec [Pipe]
    readListPrec :: ReadPrec [Pipe]
    Read, Typeable Pipe
    Typeable Pipe =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> Pipe -> c Pipe)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c Pipe)
    -> (Pipe -> Constr)
    -> (Pipe -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c Pipe))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Pipe))
    -> ((forall b. Data b => b -> b) -> Pipe -> Pipe)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Pipe -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Pipe -> r)
    -> (forall u. (forall d. Data d => d -> u) -> Pipe -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> Pipe -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> Pipe -> m Pipe)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Pipe -> m Pipe)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Pipe -> m Pipe)
    -> Data Pipe
    Pipe -> Constr
    Pipe -> DataType
    (forall b. Data b => b -> b) -> Pipe -> Pipe
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> Pipe -> u
    forall u. (forall d. Data d => d -> u) -> Pipe -> [u]
    forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Pipe -> r
    forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Pipe -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Pipe -> m Pipe
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Pipe -> m Pipe
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Pipe
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Pipe -> c Pipe
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Pipe)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Pipe)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Pipe -> c Pipe
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Pipe -> c Pipe
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Pipe
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Pipe
    $ctoConstr :: Pipe -> Constr
    toConstr :: Pipe -> Constr
    $cdataTypeOf :: Pipe -> DataType
    dataTypeOf :: Pipe -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Pipe)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Pipe)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Pipe)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Pipe)
    $cgmapT :: (forall b. Data b => b -> b) -> Pipe -> Pipe
    gmapT :: (forall b. Data b => b -> b) -> Pipe -> Pipe
    $cgmapQl :: forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Pipe -> r
    gmapQl :: forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Pipe -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Pipe -> r
    gmapQr :: forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Pipe -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> Pipe -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> Pipe -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Pipe -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Pipe -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Pipe -> m Pipe
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Pipe -> m Pipe
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Pipe -> m Pipe
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Pipe -> m Pipe
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Pipe -> m Pipe
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Pipe -> m Pipe
    Data, Typeable, (forall x. Pipe -> Rep Pipe x)
    -> (forall x. Rep Pipe x -> Pipe) -> Generic Pipe
    forall x. Rep Pipe x -> Pipe
    forall x. Pipe -> Rep Pipe x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. Pipe -> Rep Pipe x
    from :: forall x. Pipe -> Rep Pipe x
    $cto :: forall x. Rep Pipe x -> Pipe
    to :: forall x. Rep Pipe x -> Pipe
    Generic, Pipe -> Pipe -> Bool
    (Pipe -> Pipe -> Bool) -> (Pipe -> Pipe -> Bool) -> Eq Pipe
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Pipe -> Pipe -> Bool
    == :: Pipe -> Pipe -> Bool
    $c/= :: Pipe -> Pipe -> Bool
    /= :: Pipe -> Pipe -> Bool
    Eq, Eq Pipe
    Eq Pipe =>
    (Pipe -> Pipe -> Ordering)
    -> (Pipe -> Pipe -> Bool)
    -> (Pipe -> Pipe -> Bool)
    -> (Pipe -> Pipe -> Bool)
    -> (Pipe -> Pipe -> Bool)
    -> (Pipe -> Pipe -> Pipe)
    -> (Pipe -> Pipe -> Pipe)
    -> Ord Pipe
    Pipe -> Pipe -> Bool
    Pipe -> Pipe -> Ordering
    Pipe -> Pipe -> Pipe
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: Pipe -> Pipe -> Ordering
    compare :: Pipe -> Pipe -> Ordering
    $c< :: Pipe -> Pipe -> Bool
    < :: Pipe -> Pipe -> Bool
    $c<= :: Pipe -> Pipe -> Bool
    <= :: Pipe -> Pipe -> Bool
    $c> :: Pipe -> Pipe -> Bool
    > :: Pipe -> Pipe -> Bool
    $c>= :: Pipe -> Pipe -> Bool
    >= :: Pipe -> Pipe -> Bool
    $cmax :: Pipe -> Pipe -> Pipe
    max :: Pipe -> Pipe -> Pipe
    $cmin :: Pipe -> Pipe -> Pipe
    min :: Pipe -> Pipe -> Pipe
    Ord)

    data Alignment =
          LeftAligned
        | Centered
        | RightAligned
        deriving (Int -> Alignment -> ShowS
    [Alignment] -> ShowS
    Alignment -> String
    (Int -> Alignment -> ShowS)
    -> (Alignment -> String)
    -> ([Alignment] -> ShowS)
    -> Show Alignment
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Alignment -> ShowS
    showsPrec :: Int -> Alignment -> ShowS
    $cshow :: Alignment -> String
    show :: Alignment -> String
    $cshowList :: [Alignment] -> ShowS
    showList :: [Alignment] -> ShowS
    Show, ReadPrec [Alignment]
    ReadPrec Alignment
    Int -> ReadS Alignment
    ReadS [Alignment]
    (Int -> ReadS Alignment)
    -> ReadS [Alignment]
    -> ReadPrec Alignment
    -> ReadPrec [Alignment]
    -> Read Alignment
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS Alignment
    readsPrec :: Int -> ReadS Alignment
    $creadList :: ReadS [Alignment]
    readList :: ReadS [Alignment]
    $creadPrec :: ReadPrec Alignment
    readPrec :: ReadPrec Alignment
    $creadListPrec :: ReadPrec [Alignment]
    readListPrec :: ReadPrec [Alignment]
    Read, Typeable Alignment
    Typeable Alignment =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> Alignment -> c Alignment)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c Alignment)
    -> (Alignment -> Constr)
    -> (Alignment -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c Alignment))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Alignment))
    -> ((forall b. Data b => b -> b) -> Alignment -> Alignment)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> Alignment -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> Alignment -> r)
    -> (forall u. (forall d. Data d => d -> u) -> Alignment -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> Alignment -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> Alignment -> m Alignment)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Alignment -> m Alignment)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Alignment -> m Alignment)
    -> Data Alignment
    Alignment -> Constr
    Alignment -> DataType
    (forall b. Data b => b -> b) -> Alignment -> Alignment
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> Alignment -> u
    forall u. (forall d. Data d => d -> u) -> Alignment -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Alignment -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Alignment -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Alignment -> m Alignment
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Alignment -> m Alignment
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Alignment
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Alignment -> c Alignment
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Alignment)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Alignment)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Alignment -> c Alignment
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Alignment -> c Alignment
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Alignment
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Alignment
    $ctoConstr :: Alignment -> Constr
    toConstr :: Alignment -> Constr
    $cdataTypeOf :: Alignment -> DataType
    dataTypeOf :: Alignment -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Alignment)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Alignment)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Alignment)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Alignment)
    $cgmapT :: (forall b. Data b => b -> b) -> Alignment -> Alignment
    gmapT :: (forall b. Data b => b -> b) -> Alignment -> Alignment
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Alignment -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Alignment -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Alignment -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Alignment -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> Alignment -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> Alignment -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Alignment -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Alignment -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Alignment -> m Alignment
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Alignment -> m Alignment
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Alignment -> m Alignment
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Alignment -> m Alignment
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Alignment -> m Alignment
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Alignment -> m Alignment
    Data, Typeable, (forall x. Alignment -> Rep Alignment x)
    -> (forall x. Rep Alignment x -> Alignment) -> Generic Alignment
    forall x. Rep Alignment x -> Alignment
    forall x. Alignment -> Rep Alignment x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. Alignment -> Rep Alignment x
    from :: forall x. Alignment -> Rep Alignment x
    $cto :: forall x. Rep Alignment x -> Alignment
    to :: forall x. Rep Alignment x -> Alignment
    Generic, Alignment -> Alignment -> Bool
    (Alignment -> Alignment -> Bool)
    -> (Alignment -> Alignment -> Bool) -> Eq Alignment
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Alignment -> Alignment -> Bool
    == :: Alignment -> Alignment -> Bool
    $c/= :: Alignment -> Alignment -> Bool
    /= :: Alignment -> Alignment -> Bool
    Eq, Eq Alignment
    Eq Alignment =>
    (Alignment -> Alignment -> Ordering)
    -> (Alignment -> Alignment -> Bool)
    -> (Alignment -> Alignment -> Bool)
    -> (Alignment -> Alignment -> Bool)
    -> (Alignment -> Alignment -> Bool)
    -> (Alignment -> Alignment -> Alignment)
    -> (Alignment -> Alignment -> Alignment)
    -> Ord Alignment
    Alignment -> Alignment -> Bool
    Alignment -> Alignment -> Ordering
    Alignment -> Alignment -> Alignment
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: Alignment -> Alignment -> Ordering
    compare :: Alignment -> Alignment -> Ordering
    $c< :: Alignment -> Alignment -> Bool
    < :: Alignment -> Alignment -> Bool
    $c<= :: Alignment -> Alignment -> Bool
    <= :: Alignment -> Alignment -> Bool
    $c> :: Alignment -> Alignment -> Bool
    > :: Alignment -> Alignment -> Bool
    $c>= :: Alignment -> Alignment -> Bool
    >= :: Alignment -> Alignment -> Bool
    $cmax :: Alignment -> Alignment -> Alignment
    max :: Alignment -> Alignment -> Alignment
    $cmin :: Alignment -> Alignment -> Alignment
    min :: Alignment -> Alignment -> Alignment
    Ord)

    data Border = Border
         { Border -> Text
    borderLeft  :: Text
         , Border -> Text
    borderRight :: Text
         }
        deriving (Int -> Border -> ShowS
    [Border] -> ShowS
    Border -> String
    (Int -> Border -> ShowS)
    -> (Border -> String) -> ([Border] -> ShowS) -> Show Border
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Border -> ShowS
    showsPrec :: Int -> Border -> ShowS
    $cshow :: Border -> String
    show :: Border -> String
    $cshowList :: [Border] -> ShowS
    showList :: [Border] -> ShowS
    Show, ReadPrec [Border]
    ReadPrec Border
    Int -> ReadS Border
    ReadS [Border]
    (Int -> ReadS Border)
    -> ReadS [Border]
    -> ReadPrec Border
    -> ReadPrec [Border]
    -> Read Border
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS Border
    readsPrec :: Int -> ReadS Border
    $creadList :: ReadS [Border]
    readList :: ReadS [Border]
    $creadPrec :: ReadPrec Border
    readPrec :: ReadPrec Border
    $creadListPrec :: ReadPrec [Border]
    readListPrec :: ReadPrec [Border]
    Read, Typeable Border
    Typeable Border =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> Border -> c Border)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c Border)
    -> (Border -> Constr)
    -> (Border -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c Border))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Border))
    -> ((forall b. Data b => b -> b) -> Border -> Border)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> Border -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> Border -> r)
    -> (forall u. (forall d. Data d => d -> u) -> Border -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> Border -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> Border -> m Border)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Border -> m Border)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Border -> m Border)
    -> Data Border
    Border -> Constr
    Border -> DataType
    (forall b. Data b => b -> b) -> Border -> Border
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> Border -> u
    forall u. (forall d. Data d => d -> u) -> Border -> [u]
    forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Border -> r
    forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Border -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Border -> m Border
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Border -> m Border
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Border
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Border -> c Border
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Border)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Border)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Border -> c Border
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Border -> c Border
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Border
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Border
    $ctoConstr :: Border -> Constr
    toConstr :: Border -> Constr
    $cdataTypeOf :: Border -> DataType
    dataTypeOf :: Border -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Border)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Border)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Border)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Border)
    $cgmapT :: (forall b. Data b => b -> b) -> Border -> Border
    gmapT :: (forall b. Data b => b -> b) -> Border -> Border
    $cgmapQl :: forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Border -> r
    gmapQl :: forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Border -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Border -> r
    gmapQr :: forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Border -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> Border -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> Border -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Border -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Border -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Border -> m Border
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Border -> m Border
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Border -> m Border
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Border -> m Border
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Border -> m Border
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Border -> m Border
    Data, Typeable, (forall x. Border -> Rep Border x)
    -> (forall x. Rep Border x -> Border) -> Generic Border
    forall x. Rep Border x -> Border
    forall x. Border -> Rep Border x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. Border -> Rep Border x
    from :: forall x. Border -> Rep Border x
    $cto :: forall x. Rep Border x -> Border
    to :: forall x. Rep Border x -> Border
    Generic, Border -> Border -> Bool
    (Border -> Border -> Bool)
    -> (Border -> Border -> Bool) -> Eq Border
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Border -> Border -> Bool
    == :: Border -> Border -> Bool
    $c/= :: Border -> Border -> Bool
    /= :: Border -> Border -> Bool
    Eq, Eq Border
    Eq Border =>
    (Border -> Border -> Ordering)
    -> (Border -> Border -> Bool)
    -> (Border -> Border -> Bool)
    -> (Border -> Border -> Bool)
    -> (Border -> Border -> Bool)
    -> (Border -> Border -> Border)
    -> (Border -> Border -> Border)
    -> Ord Border
    Border -> Border -> Bool
    Border -> Border -> Ordering
    Border -> Border -> Border
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: Border -> Border -> Ordering
    compare :: Border -> Border -> Ordering
    $c< :: Border -> Border -> Bool
    < :: Border -> Border -> Bool
    $c<= :: Border -> Border -> Bool
    <= :: Border -> Border -> Bool
    $c> :: Border -> Border -> Bool
    > :: Border -> Border -> Bool
    $c>= :: Border -> Border -> Bool
    >= :: Border -> Border -> Bool
    $cmax :: Border -> Border -> Border
    max :: Border -> Border -> Border
    $cmin :: Border -> Border -> Border
    min :: Border -> Border -> Border
    Ord)

    -- | A variable which may have several parts (@foo.bar.baz@).
    data Variable =
      Variable
        { Variable -> [Text]
    varParts   :: [Text]
        , Variable -> [Pipe]
    varPipes   :: [Pipe]
        }
      deriving (Int -> Variable -> ShowS
    [Variable] -> ShowS
    Variable -> String
    (Int -> Variable -> ShowS)
    -> (Variable -> String) -> ([Variable] -> ShowS) -> Show Variable
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Variable -> ShowS
    showsPrec :: Int -> Variable -> ShowS
    $cshow :: Variable -> String
    show :: Variable -> String
    $cshowList :: [Variable] -> ShowS
    showList :: [Variable] -> ShowS
    Show, ReadPrec [Variable]
    ReadPrec Variable
    Int -> ReadS Variable
    ReadS [Variable]
    (Int -> ReadS Variable)
    -> ReadS [Variable]
    -> ReadPrec Variable
    -> ReadPrec [Variable]
    -> Read Variable
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS Variable
    readsPrec :: Int -> ReadS Variable
    $creadList :: ReadS [Variable]
    readList :: ReadS [Variable]
    $creadPrec :: ReadPrec Variable
    readPrec :: ReadPrec Variable
    $creadListPrec :: ReadPrec [Variable]
    readListPrec :: ReadPrec [Variable]
    Read, Typeable Variable
    Typeable Variable =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> Variable -> c Variable)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c Variable)
    -> (Variable -> Constr)
    -> (Variable -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c Variable))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Variable))
    -> ((forall b. Data b => b -> b) -> Variable -> Variable)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> Variable -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> Variable -> r)
    -> (forall u. (forall d. Data d => d -> u) -> Variable -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> Variable -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> Variable -> m Variable)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Variable -> m Variable)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Variable -> m Variable)
    -> Data Variable
    Variable -> Constr
    Variable -> DataType
    (forall b. Data b => b -> b) -> Variable -> Variable
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> Variable -> u
    forall u. (forall d. Data d => d -> u) -> Variable -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Variable -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Variable -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Variable -> m Variable
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Variable -> m Variable
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Variable
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Variable -> c Variable
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Variable)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Variable)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Variable -> c Variable
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Variable -> c Variable
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Variable
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Variable
    $ctoConstr :: Variable -> Constr
    toConstr :: Variable -> Constr
    $cdataTypeOf :: Variable -> DataType
    dataTypeOf :: Variable -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Variable)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Variable)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Variable)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Variable)
    $cgmapT :: (forall b. Data b => b -> b) -> Variable -> Variable
    gmapT :: (forall b. Data b => b -> b) -> Variable -> Variable
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Variable -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Variable -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Variable -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Variable -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> Variable -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> Variable -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Variable -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Variable -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Variable -> m Variable
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Variable -> m Variable
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Variable -> m Variable
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Variable -> m Variable
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Variable -> m Variable
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Variable -> m Variable
    Data, Typeable, (forall x. Variable -> Rep Variable x)
    -> (forall x. Rep Variable x -> Variable) -> Generic Variable
    forall x. Rep Variable x -> Variable
    forall x. Variable -> Rep Variable x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. Variable -> Rep Variable x
    from :: forall x. Variable -> Rep Variable x
    $cto :: forall x. Rep Variable x -> Variable
    to :: forall x. Rep Variable x -> Variable
    Generic, Variable -> Variable -> Bool
    (Variable -> Variable -> Bool)
    -> (Variable -> Variable -> Bool) -> Eq Variable
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Variable -> Variable -> Bool
    == :: Variable -> Variable -> Bool
    $c/= :: Variable -> Variable -> Bool
    /= :: Variable -> Variable -> Bool
    Eq, Eq Variable
    Eq Variable =>
    (Variable -> Variable -> Ordering)
    -> (Variable -> Variable -> Bool)
    -> (Variable -> Variable -> Bool)
    -> (Variable -> Variable -> Bool)
    -> (Variable -> Variable -> Bool)
    -> (Variable -> Variable -> Variable)
    -> (Variable -> Variable -> Variable)
    -> Ord Variable
    Variable -> Variable -> Bool
    Variable -> Variable -> Ordering
    Variable -> Variable -> Variable
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: Variable -> Variable -> Ordering
    compare :: Variable -> Variable -> Ordering
    $c< :: Variable -> Variable -> Bool
    < :: Variable -> Variable -> Bool
    $c<= :: Variable -> Variable -> Bool
    <= :: Variable -> Variable -> Bool
    $c> :: Variable -> Variable -> Bool
    > :: Variable -> Variable -> Bool
    $c>= :: Variable -> Variable -> Bool
    >= :: Variable -> Variable -> Bool
    $cmax :: Variable -> Variable -> Variable
    max :: Variable -> Variable -> Variable
    $cmin :: Variable -> Variable -> Variable
    min :: Variable -> Variable -> Variable
    Ord)

    instance Semigroup Variable where
      Variable [Text]
    xs [Pipe]
    fs <> :: Variable -> Variable -> Variable
    <> Variable [Text]
    ys [Pipe]
    gs = [Text] -> [Pipe] -> Variable
    Variable ([Text]
    xs [Text] -> [Text] -> [Text]
    forall a. Semigroup a => a -> a -> a
    <> [Text]
    ys) ([Pipe]
    fs [Pipe] -> [Pipe] -> [Pipe]
    forall a. Semigroup a => a -> a -> a
    <> [Pipe]
    gs)

    instance Monoid Variable where
      mempty :: Variable
    mempty = [Text] -> [Pipe] -> Variable
    Variable [Text]
    forall a. Monoid a => a
    mempty [Pipe]
    forall a. Monoid a => a
    mempty
      mappend :: Variable -> Variable -> Variable
    mappend = Variable -> Variable -> Variable
    forall a. Semigroup a => a -> a -> a
    (<>)

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

    -- | A 'Context' defines values for template's variables.
    newtype Context a = Context { forall a. Context a -> Map Text (Val a)
    unContext :: M.Map Text (Val a) }
      deriving (Int -> Context a -> ShowS
    [Context a] -> ShowS
    Context a -> String
    (Int -> Context a -> ShowS)
    -> (Context a -> String)
    -> ([Context a] -> ShowS)
    -> Show (Context a)
    forall a. Show a => Int -> Context a -> ShowS
    forall a. Show a => [Context a] -> ShowS
    forall a. Show a => Context a -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: forall a. Show a => Int -> Context a -> ShowS
    showsPrec :: Int -> Context a -> ShowS
    $cshow :: forall a. Show a => Context a -> String
    show :: Context a -> String
    $cshowList :: forall a. Show a => [Context a] -> ShowS
    showList :: [Context a] -> ShowS
    Show, NonEmpty (Context a) -> Context a
    Context a -> Context a -> Context a
    (Context a -> Context a -> Context a)
    -> (NonEmpty (Context a) -> Context a)
    -> (forall b. Integral b => b -> Context a -> Context a)
    -> Semigroup (Context a)
    forall b. Integral b => b -> Context a -> Context a
    forall a. NonEmpty (Context a) -> Context a
    forall a. Context a -> Context a -> Context a
    forall a.
    (a -> a -> a)
    -> (NonEmpty a -> a)
    -> (forall b. Integral b => b -> a -> a)
    -> Semigroup a
    forall a b. Integral b => b -> Context a -> Context a
    $c<> :: forall a. Context a -> Context a -> Context a
    <> :: Context a -> Context a -> Context a
    $csconcat :: forall a. NonEmpty (Context a) -> Context a
    sconcat :: NonEmpty (Context a) -> Context a
    $cstimes :: forall a b. Integral b => b -> Context a -> Context a
    stimes :: forall b. Integral b => b -> Context a -> Context a
    Semigroup, Semigroup (Context a)
    Context a
    Semigroup (Context a) =>
    Context a
    -> (Context a -> Context a -> Context a)
    -> ([Context a] -> Context a)
    -> Monoid (Context a)
    [Context a] -> Context a
    Context a -> Context a -> Context a
    forall a. Semigroup (Context a)
    forall a. Context a
    forall a.
    Semigroup a =>
    a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
    forall a. [Context a] -> Context a
    forall a. Context a -> Context a -> Context a
    $cmempty :: forall a. Context a
    mempty :: Context a
    $cmappend :: forall a. Context a -> Context a -> Context a
    mappend :: Context a -> Context a -> Context a
    $cmconcat :: forall a. [Context a] -> Context a
    mconcat :: [Context a] -> Context a
    Monoid, Functor Context
    Foldable Context
    (Functor Context, Foldable Context) =>
    (forall (f :: * -> *) a b.
     Applicative f =>
     (a -> f b) -> Context a -> f (Context b))
    -> (forall (f :: * -> *) a.
        Applicative f =>
        Context (f a) -> f (Context a))
    -> (forall (m :: * -> *) a b.
        Monad m =>
        (a -> m b) -> Context a -> m (Context b))
    -> (forall (m :: * -> *) a.
        Monad m =>
        Context (m a) -> m (Context a))
    -> Traversable Context
    forall (t :: * -> *).
    (Functor t, Foldable t) =>
    (forall (f :: * -> *) a b.
     Applicative f =>
     (a -> f b) -> t a -> f (t b))
    -> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
    -> (forall (m :: * -> *) a b.
        Monad m =>
        (a -> m b) -> t a -> m (t b))
    -> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
    -> Traversable t
    forall (m :: * -> *) a. Monad m => Context (m a) -> m (Context a)
    forall (f :: * -> *) a.
    Applicative f =>
    Context (f a) -> f (Context a)
    forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Context a -> m (Context b)
    forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> Context a -> f (Context b)
    $ctraverse :: forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> Context a -> f (Context b)
    traverse :: forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> Context a -> f (Context b)
    $csequenceA :: forall (f :: * -> *) a.
    Applicative f =>
    Context (f a) -> f (Context a)
    sequenceA :: forall (f :: * -> *) a.
    Applicative f =>
    Context (f a) -> f (Context a)
    $cmapM :: forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Context a -> m (Context b)
    mapM :: forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Context a -> m (Context b)
    $csequence :: forall (m :: * -> *) a. Monad m => Context (m a) -> m (Context a)
    sequence :: forall (m :: * -> *) a. Monad m => Context (m a) -> m (Context a)
    Traversable, (forall m. Monoid m => Context m -> m)
    -> (forall m a. Monoid m => (a -> m) -> Context a -> m)
    -> (forall m a. Monoid m => (a -> m) -> Context a -> m)
    -> (forall a b. (a -> b -> b) -> b -> Context a -> b)
    -> (forall a b. (a -> b -> b) -> b -> Context a -> b)
    -> (forall b a. (b -> a -> b) -> b -> Context a -> b)
    -> (forall b a. (b -> a -> b) -> b -> Context a -> b)
    -> (forall a. (a -> a -> a) -> Context a -> a)
    -> (forall a. (a -> a -> a) -> Context a -> a)
    -> (forall a. Context a -> [a])
    -> (forall a. Context a -> Bool)
    -> (forall a. Context a -> Int)
    -> (forall a. Eq a => a -> Context a -> Bool)
    -> (forall a. Ord a => Context a -> a)
    -> (forall a. Ord a => Context a -> a)
    -> (forall a. Num a => Context a -> a)
    -> (forall a. Num a => Context a -> a)
    -> Foldable Context
    forall a. Eq a => a -> Context a -> Bool
    forall a. Num a => Context a -> a
    forall a. Ord a => Context a -> a
    forall m. Monoid m => Context m -> m
    forall a. Context a -> Bool
    forall a. Context a -> Int
    forall a. Context a -> [a]
    forall a. (a -> a -> a) -> Context a -> a
    forall m a. Monoid m => (a -> m) -> Context a -> m
    forall b a. (b -> a -> b) -> b -> Context a -> b
    forall a b. (a -> b -> b) -> b -> Context a -> b
    forall (t :: * -> *).
    (forall m. Monoid m => t m -> m)
    -> (forall m a. Monoid m => (a -> m) -> t a -> m)
    -> (forall m a. Monoid m => (a -> m) -> t a -> m)
    -> (forall a b. (a -> b -> b) -> b -> t a -> b)
    -> (forall a b. (a -> b -> b) -> b -> t a -> b)
    -> (forall b a. (b -> a -> b) -> b -> t a -> b)
    -> (forall b a. (b -> a -> b) -> b -> t a -> b)
    -> (forall a. (a -> a -> a) -> t a -> a)
    -> (forall a. (a -> a -> a) -> t a -> a)
    -> (forall a. t a -> [a])
    -> (forall a. t a -> Bool)
    -> (forall a. t a -> Int)
    -> (forall a. Eq a => a -> t a -> Bool)
    -> (forall a. Ord a => t a -> a)
    -> (forall a. Ord a => t a -> a)
    -> (forall a. Num a => t a -> a)
    -> (forall a. Num a => t a -> a)
    -> Foldable t
    $cfold :: forall m. Monoid m => Context m -> m
    fold :: forall m. Monoid m => Context m -> m
    $cfoldMap :: forall m a. Monoid m => (a -> m) -> Context a -> m
    foldMap :: forall m a. Monoid m => (a -> m) -> Context a -> m
    $cfoldMap' :: forall m a. Monoid m => (a -> m) -> Context a -> m
    foldMap' :: forall m a. Monoid m => (a -> m) -> Context a -> m
    $cfoldr :: forall a b. (a -> b -> b) -> b -> Context a -> b
    foldr :: forall a b. (a -> b -> b) -> b -> Context a -> b
    $cfoldr' :: forall a b. (a -> b -> b) -> b -> Context a -> b
    foldr' :: forall a b. (a -> b -> b) -> b -> Context a -> b
    $cfoldl :: forall b a. (b -> a -> b) -> b -> Context a -> b
    foldl :: forall b a. (b -> a -> b) -> b -> Context a -> b
    $cfoldl' :: forall b a. (b -> a -> b) -> b -> Context a -> b
    foldl' :: forall b a. (b -> a -> b) -> b -> Context a -> b
    $cfoldr1 :: forall a. (a -> a -> a) -> Context a -> a
    foldr1 :: forall a. (a -> a -> a) -> Context a -> a
    $cfoldl1 :: forall a. (a -> a -> a) -> Context a -> a
    foldl1 :: forall a. (a -> a -> a) -> Context a -> a
    $ctoList :: forall a. Context a -> [a]
    toList :: forall a. Context a -> [a]
    $cnull :: forall a. Context a -> Bool
    null :: forall a. Context a -> Bool
    $clength :: forall a. Context a -> Int
    length :: forall a. Context a -> Int
    $celem :: forall a. Eq a => a -> Context a -> Bool
    elem :: forall a. Eq a => a -> Context a -> Bool
    $cmaximum :: forall a. Ord a => Context a -> a
    maximum :: forall a. Ord a => Context a -> a
    $cminimum :: forall a. Ord a => Context a -> a
    minimum :: forall a. Ord a => Context a -> a
    $csum :: forall a. Num a => Context a -> a
    sum :: forall a. Num a => Context a -> a
    $cproduct :: forall a. Num a => Context a -> a
    product :: forall a. Num a => Context a -> a
    Foldable, (forall a b. (a -> b) -> Context a -> Context b)
    -> (forall a b. a -> Context b -> Context a) -> Functor Context
    forall a b. a -> Context b -> Context a
    forall a b. (a -> b) -> Context a -> Context b
    forall (f :: * -> *).
    (forall a b. (a -> b) -> f a -> f b)
    -> (forall a b. a -> f b -> f a) -> Functor f
    $cfmap :: forall a b. (a -> b) -> Context a -> Context b
    fmap :: forall a b. (a -> b) -> Context a -> Context b
    $c<$ :: forall a b. a -> Context b -> Context a
    <$ :: forall a b. a -> Context b -> Context a
    Functor,
                Typeable (Context a)
    Typeable (Context a) =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> Context a -> c (Context a))
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c (Context a))
    -> (Context a -> Constr)
    -> (Context a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c (Context a)))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e))
        -> Maybe (c (Context a)))
    -> ((forall b. Data b => b -> b) -> Context a -> Context a)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> Context a -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> Context a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> Context a -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> Context a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> Context a -> m (Context a))
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Context a -> m (Context a))
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Context a -> m (Context a))
    -> Data (Context a)
    Context a -> Constr
    Context a -> DataType
    (forall b. Data b => b -> b) -> Context a -> Context a
    forall a. Data a => Typeable (Context a)
    forall a. Data a => Context a -> Constr
    forall a. Data a => Context a -> DataType
    forall a.
    Data a =>
    (forall b. Data b => b -> b) -> Context a -> Context a
    forall a u.
    Data a =>
    Int -> (forall d. Data d => d -> u) -> Context a -> u
    forall a u.
    Data a =>
    (forall d. Data d => d -> u) -> Context a -> [u]
    forall a r r'.
    Data a =>
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Context a -> r
    forall a r r'.
    Data a =>
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Context a -> r
    forall a (m :: * -> *).
    (Data a, Monad m) =>
    (forall d. Data d => d -> m d) -> Context a -> m (Context a)
    forall a (m :: * -> *).
    (Data a, MonadPlus m) =>
    (forall d. Data d => d -> m d) -> Context a -> m (Context a)
    forall a (c :: * -> *).
    Data a =>
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Context a)
    forall a (c :: * -> *).
    Data a =>
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Context a -> c (Context a)
    forall a (t :: * -> *) (c :: * -> *).
    (Data a, Typeable t) =>
    (forall d. Data d => c (t d)) -> Maybe (c (Context a))
    forall a (t :: * -> * -> *) (c :: * -> *).
    (Data a, Typeable t) =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (Context a))
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> Context a -> u
    forall u. (forall d. Data d => d -> u) -> Context a -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Context a -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Context a -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Context a -> m (Context a)
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Context a -> m (Context a)
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Context a)
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Context a -> c (Context a)
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Context a))
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (Context a))
    $cgfoldl :: forall a (c :: * -> *).
    Data a =>
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Context a -> c (Context a)
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Context a -> c (Context a)
    $cgunfold :: forall a (c :: * -> *).
    Data a =>
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Context a)
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Context a)
    $ctoConstr :: forall a. Data a => Context a -> Constr
    toConstr :: Context a -> Constr
    $cdataTypeOf :: forall a. Data a => Context a -> DataType
    dataTypeOf :: Context a -> DataType
    $cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
    (Data a, Typeable t) =>
    (forall d. Data d => c (t d)) -> Maybe (c (Context a))
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Context a))
    $cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
    (Data a, Typeable t) =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (Context a))
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (Context a))
    $cgmapT :: forall a.
    Data a =>
    (forall b. Data b => b -> b) -> Context a -> Context a
    gmapT :: (forall b. Data b => b -> b) -> Context a -> Context a
    $cgmapQl :: forall a r r'.
    Data a =>
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Context a -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Context a -> r
    $cgmapQr :: forall a r r'.
    Data a =>
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Context a -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Context a -> r
    $cgmapQ :: forall a u.
    Data a =>
    (forall d. Data d => d -> u) -> Context a -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> Context a -> [u]
    $cgmapQi :: forall a u.
    Data a =>
    Int -> (forall d. Data d => d -> u) -> Context a -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Context a -> u
    $cgmapM :: forall a (m :: * -> *).
    (Data a, Monad m) =>
    (forall d. Data d => d -> m d) -> Context a -> m (Context a)
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Context a -> m (Context a)
    $cgmapMp :: forall a (m :: * -> *).
    (Data a, MonadPlus m) =>
    (forall d. Data d => d -> m d) -> Context a -> m (Context a)
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Context a -> m (Context a)
    $cgmapMo :: forall a (m :: * -> *).
    (Data a, MonadPlus m) =>
    (forall d. Data d => d -> m d) -> Context a -> m (Context a)
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Context a -> m (Context a)
    Data, Typeable)

    -- | A variable value.
    data Val a =
        SimpleVal  (Doc a)
      | ListVal    [Val a]
      | MapVal     (Context a)
      | BoolVal    Bool
      | NullVal
      deriving (Int -> Val a -> ShowS
    [Val a] -> ShowS
    Val a -> String
    (Int -> Val a -> ShowS)
    -> (Val a -> String) -> ([Val a] -> ShowS) -> Show (Val a)
    forall a. Show a => Int -> Val a -> ShowS
    forall a. Show a => [Val a] -> ShowS
    forall a. Show a => Val a -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: forall a. Show a => Int -> Val a -> ShowS
    showsPrec :: Int -> Val a -> ShowS
    $cshow :: forall a. Show a => Val a -> String
    show :: Val a -> String
    $cshowList :: forall a. Show a => [Val a] -> ShowS
    showList :: [Val a] -> ShowS
    Show, Functor Val
    Foldable Val
    (Functor Val, Foldable Val) =>
    (forall (f :: * -> *) a b.
     Applicative f =>
     (a -> f b) -> Val a -> f (Val b))
    -> (forall (f :: * -> *) a.
        Applicative f =>
        Val (f a) -> f (Val a))
    -> (forall (m :: * -> *) a b.
        Monad m =>
        (a -> m b) -> Val a -> m (Val b))
    -> (forall (m :: * -> *) a. Monad m => Val (m a) -> m (Val a))
    -> Traversable Val
    forall (t :: * -> *).
    (Functor t, Foldable t) =>
    (forall (f :: * -> *) a b.
     Applicative f =>
     (a -> f b) -> t a -> f (t b))
    -> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
    -> (forall (m :: * -> *) a b.
        Monad m =>
        (a -> m b) -> t a -> m (t b))
    -> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
    -> Traversable t
    forall (m :: * -> *) a. Monad m => Val (m a) -> m (Val a)
    forall (f :: * -> *) a. Applicative f => Val (f a) -> f (Val a)
    forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Val a -> m (Val b)
    forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> Val a -> f (Val b)
    $ctraverse :: forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> Val a -> f (Val b)
    traverse :: forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> Val a -> f (Val b)
    $csequenceA :: forall (f :: * -> *) a. Applicative f => Val (f a) -> f (Val a)
    sequenceA :: forall (f :: * -> *) a. Applicative f => Val (f a) -> f (Val a)
    $cmapM :: forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Val a -> m (Val b)
    mapM :: forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Val a -> m (Val b)
    $csequence :: forall (m :: * -> *) a. Monad m => Val (m a) -> m (Val a)
    sequence :: forall (m :: * -> *) a. Monad m => Val (m a) -> m (Val a)
    Traversable, (forall m. Monoid m => Val m -> m)
    -> (forall m a. Monoid m => (a -> m) -> Val a -> m)
    -> (forall m a. Monoid m => (a -> m) -> Val a -> m)
    -> (forall a b. (a -> b -> b) -> b -> Val a -> b)
    -> (forall a b. (a -> b -> b) -> b -> Val a -> b)
    -> (forall b a. (b -> a -> b) -> b -> Val a -> b)
    -> (forall b a. (b -> a -> b) -> b -> Val a -> b)
    -> (forall a. (a -> a -> a) -> Val a -> a)
    -> (forall a. (a -> a -> a) -> Val a -> a)
    -> (forall a. Val a -> [a])
    -> (forall a. Val a -> Bool)
    -> (forall a. Val a -> Int)
    -> (forall a. Eq a => a -> Val a -> Bool)
    -> (forall a. Ord a => Val a -> a)
    -> (forall a. Ord a => Val a -> a)
    -> (forall a. Num a => Val a -> a)
    -> (forall a. Num a => Val a -> a)
    -> Foldable Val
    forall a. Eq a => a -> Val a -> Bool
    forall a. Num a => Val a -> a
    forall a. Ord a => Val a -> a
    forall m. Monoid m => Val m -> m
    forall a. Val a -> Bool
    forall a. Val a -> Int
    forall a. Val a -> [a]
    forall a. (a -> a -> a) -> Val a -> a
    forall m a. Monoid m => (a -> m) -> Val a -> m
    forall b a. (b -> a -> b) -> b -> Val a -> b
    forall a b. (a -> b -> b) -> b -> Val a -> b
    forall (t :: * -> *).
    (forall m. Monoid m => t m -> m)
    -> (forall m a. Monoid m => (a -> m) -> t a -> m)
    -> (forall m a. Monoid m => (a -> m) -> t a -> m)
    -> (forall a b. (a -> b -> b) -> b -> t a -> b)
    -> (forall a b. (a -> b -> b) -> b -> t a -> b)
    -> (forall b a. (b -> a -> b) -> b -> t a -> b)
    -> (forall b a. (b -> a -> b) -> b -> t a -> b)
    -> (forall a. (a -> a -> a) -> t a -> a)
    -> (forall a. (a -> a -> a) -> t a -> a)
    -> (forall a. t a -> [a])
    -> (forall a. t a -> Bool)
    -> (forall a. t a -> Int)
    -> (forall a. Eq a => a -> t a -> Bool)
    -> (forall a. Ord a => t a -> a)
    -> (forall a. Ord a => t a -> a)
    -> (forall a. Num a => t a -> a)
    -> (forall a. Num a => t a -> a)
    -> Foldable t
    $cfold :: forall m. Monoid m => Val m -> m
    fold :: forall m. Monoid m => Val m -> m
    $cfoldMap :: forall m a. Monoid m => (a -> m) -> Val a -> m
    foldMap :: forall m a. Monoid m => (a -> m) -> Val a -> m
    $cfoldMap' :: forall m a. Monoid m => (a -> m) -> Val a -> m
    foldMap' :: forall m a. Monoid m => (a -> m) -> Val a -> m
    $cfoldr :: forall a b. (a -> b -> b) -> b -> Val a -> b
    foldr :: forall a b. (a -> b -> b) -> b -> Val a -> b
    $cfoldr' :: forall a b. (a -> b -> b) -> b -> Val a -> b
    foldr' :: forall a b. (a -> b -> b) -> b -> Val a -> b
    $cfoldl :: forall b a. (b -> a -> b) -> b -> Val a -> b
    foldl :: forall b a. (b -> a -> b) -> b -> Val a -> b
    $cfoldl' :: forall b a. (b -> a -> b) -> b -> Val a -> b
    foldl' :: forall b a. (b -> a -> b) -> b -> Val a -> b
    $cfoldr1 :: forall a. (a -> a -> a) -> Val a -> a
    foldr1 :: forall a. (a -> a -> a) -> Val a -> a
    $cfoldl1 :: forall a. (a -> a -> a) -> Val a -> a
    foldl1 :: forall a. (a -> a -> a) -> Val a -> a
    $ctoList :: forall a. Val a -> [a]
    toList :: forall a. Val a -> [a]
    $cnull :: forall a. Val a -> Bool
    null :: forall a. Val a -> Bool
    $clength :: forall a. Val a -> Int
    length :: forall a. Val a -> Int
    $celem :: forall a. Eq a => a -> Val a -> Bool
    elem :: forall a. Eq a => a -> Val a -> Bool
    $cmaximum :: forall a. Ord a => Val a -> a
    maximum :: forall a. Ord a => Val a -> a
    $cminimum :: forall a. Ord a => Val a -> a
    minimum :: forall a. Ord a => Val a -> a
    $csum :: forall a. Num a => Val a -> a
    sum :: forall a. Num a => Val a -> a
    $cproduct :: forall a. Num a => Val a -> a
    product :: forall a. Num a => Val a -> a
    Foldable, (forall a b. (a -> b) -> Val a -> Val b)
    -> (forall a b. a -> Val b -> Val a) -> Functor Val
    forall a b. a -> Val b -> Val a
    forall a b. (a -> b) -> Val a -> Val b
    forall (f :: * -> *).
    (forall a b. (a -> b) -> f a -> f b)
    -> (forall a b. a -> f b -> f a) -> Functor f
    $cfmap :: forall a b. (a -> b) -> Val a -> Val b
    fmap :: forall a b. (a -> b) -> Val a -> Val b
    $c<$ :: forall a b. a -> Val b -> Val a
    <$ :: forall a b. a -> Val b -> Val a
    Functor, Typeable (Val a)
    Typeable (Val a) =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> Val a -> c (Val a))
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c (Val a))
    -> (Val a -> Constr)
    -> (Val a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c (Val a)))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Val a)))
    -> ((forall b. Data b => b -> b) -> Val a -> Val a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Val a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Val a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> Val a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> Val a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> Val a -> m (Val a))
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Val a -> m (Val a))
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Val a -> m (Val a))
    -> Data (Val a)
    Val a -> Constr
    Val a -> DataType
    (forall b. Data b => b -> b) -> Val a -> Val a
    forall a. Data a => Typeable (Val a)
    forall a. Data a => Val a -> Constr
    forall a. Data a => Val a -> DataType
    forall a. Data a => (forall b. Data b => b -> b) -> Val a -> Val a
    forall a u.
    Data a =>
    Int -> (forall d. Data d => d -> u) -> Val a -> u
    forall a u. Data a => (forall d. Data d => d -> u) -> Val a -> [u]
    forall a r r'.
    Data a =>
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Val a -> r
    forall a r r'.
    Data a =>
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Val a -> r
    forall a (m :: * -> *).
    (Data a, Monad m) =>
    (forall d. Data d => d -> m d) -> Val a -> m (Val a)
    forall a (m :: * -> *).
    (Data a, MonadPlus m) =>
    (forall d. Data d => d -> m d) -> Val a -> m (Val a)
    forall a (c :: * -> *).
    Data a =>
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Val a)
    forall a (c :: * -> *).
    Data a =>
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Val a -> c (Val a)
    forall a (t :: * -> *) (c :: * -> *).
    (Data a, Typeable t) =>
    (forall d. Data d => c (t d)) -> Maybe (c (Val a))
    forall a (t :: * -> * -> *) (c :: * -> *).
    (Data a, Typeable t) =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Val a))
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> Val a -> u
    forall u. (forall d. Data d => d -> u) -> Val a -> [u]
    forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Val a -> r
    forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Val a -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Val a -> m (Val a)
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Val a -> m (Val a)
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Val a)
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Val a -> c (Val a)
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Val a))
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Val a))
    $cgfoldl :: forall a (c :: * -> *).
    Data a =>
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Val a -> c (Val a)
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Val a -> c (Val a)
    $cgunfold :: forall a (c :: * -> *).
    Data a =>
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Val a)
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Val a)
    $ctoConstr :: forall a. Data a => Val a -> Constr
    toConstr :: Val a -> Constr
    $cdataTypeOf :: forall a. Data a => Val a -> DataType
    dataTypeOf :: Val a -> DataType
    $cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
    (Data a, Typeable t) =>
    (forall d. Data d => c (t d)) -> Maybe (c (Val a))
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Val a))
    $cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
    (Data a, Typeable t) =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Val a))
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Val a))
    $cgmapT :: forall a. Data a => (forall b. Data b => b -> b) -> Val a -> Val a
    gmapT :: (forall b. Data b => b -> b) -> Val a -> Val a
    $cgmapQl :: forall a r r'.
    Data a =>
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Val a -> r
    gmapQl :: forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Val a -> r
    $cgmapQr :: forall a r r'.
    Data a =>
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Val a -> r
    gmapQr :: forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Val a -> r
    $cgmapQ :: forall a u. Data a => (forall d. Data d => d -> u) -> Val a -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> Val a -> [u]
    $cgmapQi :: forall a u.
    Data a =>
    Int -> (forall d. Data d => d -> u) -> Val a -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Val a -> u
    $cgmapM :: forall a (m :: * -> *).
    (Data a, Monad m) =>
    (forall d. Data d => d -> m d) -> Val a -> m (Val a)
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Val a -> m (Val a)
    $cgmapMp :: forall a (m :: * -> *).
    (Data a, MonadPlus m) =>
    (forall d. Data d => d -> m d) -> Val a -> m (Val a)
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Val a -> m (Val a)
    $cgmapMo :: forall a (m :: * -> *).
    (Data a, MonadPlus m) =>
    (forall d. Data d => d -> m d) -> Val a -> m (Val a)
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Val a -> m (Val a)
    Data, Typeable)

    -- | The 'ToContext' class provides automatic conversion to
    -- a 'Context' or 'Val'.
    class ToContext a b where
      toContext :: b -> Context a
      toContext b
    x = case b -> Val a
    forall a b. ToContext a b => b -> Val a
    toVal b
    x of
                      MapVal Context a
    c -> Context a
    c
                      Val a
    _        -> Context a
    forall a. Monoid a => a
    mempty
      toVal     :: b -> Val a

    instance ToContext a (Context a) where
      toContext :: Context a -> Context a
    toContext = Context a -> Context a
    forall a. a -> a
    id
      toVal :: Context a -> Val a
    toVal     = Context a -> Val a
    forall a. Context a -> Val a
    MapVal

    instance ToContext a (Val a) where
      toVal :: Val a -> Val a
    toVal     = Val a -> Val a
    forall a. a -> a
    id

    instance TemplateTarget a => ToContext a a where
      toVal :: a -> Val a
    toVal     = Doc a -> Val a
    forall a. Doc a -> Val a
    SimpleVal (Doc a -> Val a) -> (a -> Doc a) -> a -> Val a
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . a -> Doc a
    forall a. HasChars a => a -> Doc a
    DL.literal

    instance ToContext a a => ToContext a (Doc a) where
      toVal :: Doc a -> Val a
    toVal     = Doc a -> Val a
    forall a. Doc a -> Val a
    SimpleVal

    instance ToContext a b => ToContext a [b] where
      toVal :: [b] -> Val a
    toVal     = [Val a] -> Val a
    forall a. [Val a] -> Val a
    ListVal ([Val a] -> Val a) -> ([b] -> [Val a]) -> [b] -> Val a
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (b -> Val a) -> [b] -> [Val a]
    forall a b. (a -> b) -> [a] -> [b]
    map b -> Val a
    forall a b. ToContext a b => b -> Val a
    toVal

    instance {-# OVERLAPPING #-} TemplateTarget [a] => ToContext [a] [a] where
      toVal :: [a] -> Val [a]
    toVal    = Doc [a] -> Val [a]
    forall a. Doc a -> Val a
    SimpleVal (Doc [a] -> Val [a]) -> ([a] -> Doc [a]) -> [a] -> Val [a]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [a] -> Doc [a]
    forall a. HasChars a => a -> Doc a
    DL.literal

    instance ToContext a b => ToContext a (M.Map Text b) where
      toVal :: Map Text b -> Val a
    toVal     = Context a -> Val a
    forall a. Context a -> Val a
    MapVal (Context a -> Val a)
    -> (Map Text b -> Context a) -> Map Text b -> Val a
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Map Text b -> Context a
    forall a b. ToContext a b => b -> Context a
    toContext
      toContext :: Map Text b -> Context a
    toContext = Map Text (Val a) -> Context a
    forall a. Map Text (Val a) -> Context a
    Context (Map Text (Val a) -> Context a)
    -> (Map Text b -> Map Text (Val a)) -> Map Text b -> Context a
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (b -> Val a) -> Map Text b -> Map Text (Val a)
    forall a b k. (a -> b) -> Map k a -> Map k b
    M.map b -> Val a
    forall a b. ToContext a b => b -> Val a
    toVal

    instance TemplateTarget a => ToContext a Bool where
      toVal :: Bool -> Val a
    toVal Bool
    True  = Bool -> Val a
    forall a. Bool -> Val a
    BoolVal Bool
    True
      toVal Bool
    False = Bool -> Val a
    forall a. Bool -> Val a
    BoolVal Bool
    False

    instance TemplateTarget a => ToContext a Value where
      toContext :: Value -> Context a
    toContext Value
    x = case Value -> Result (Context a)
    forall a. FromJSON a => Value -> Result a
    fromJSON Value
    x of
                      Success Context a
    y -> Context a
    y
                      Error String
    _   -> Context a
    forall a. Monoid a => a
    mempty
      toVal :: Value -> Val a
    toVal Value
    x = case Value -> Result (Val a)
    forall a. FromJSON a => Value -> Result a
    fromJSON Value
    x of
                      Success Val a
    y -> Val a
    y
                      Error String
    _   -> Val a
    forall a. Val a
    NullVal

    -- | The 'FromContext' class provides functions for extracting
    -- values from 'Val' and 'Context'.
    class FromContext a b where
      fromVal :: Val a -> Maybe b
      lookupContext :: Text -> Context a -> Maybe b
      lookupContext Text
    t (Context Map Text (Val a)
    m) = Text -> Map Text (Val a) -> Maybe (Val a)
    forall k a. Ord k => k -> Map k a -> Maybe a
    M.lookup Text
    t Map Text (Val a)
    m Maybe (Val a) -> (Val a -> Maybe b) -> Maybe b
    forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= Val a -> Maybe b
    forall a b. FromContext a b => Val a -> Maybe b
    fromVal

    instance TemplateTarget a => FromContext a (Val a) where
      fromVal :: Val a -> Maybe (Val a)
    fromVal = Val a -> Maybe (Val a)
    forall a. a -> Maybe a
    Just

    instance TemplateTarget a => FromContext a (Doc a) where
      fromVal :: Val a -> Maybe (Doc a)
    fromVal (SimpleVal Doc a
    x) = Doc a -> Maybe (Doc a)
    forall a. a -> Maybe a
    Just Doc a
    x
      fromVal Val a
    _             = Maybe (Doc a)
    forall a. Maybe a
    Nothing

    instance TemplateTarget a => FromContext a a where
      fromVal :: Val a -> Maybe a
    fromVal (SimpleVal Doc a
    x) = a -> Maybe a
    forall a. a -> Maybe a
    Just (Maybe Int -> Doc a -> a
    forall a. HasChars a => Maybe Int -> Doc a -> a
    DL.render Maybe Int
    forall a. Maybe a
    Nothing Doc a
    x)
      fromVal Val a
    _             = Maybe a
    forall a. Maybe a
    Nothing

    instance {-# OVERLAPPING #-} TemplateTarget [a] => FromContext [a] [a] where
      fromVal :: Val [a] -> Maybe [a]
    fromVal (SimpleVal Doc [a]
    x) = [a] -> Maybe [a]
    forall a. a -> Maybe a
    Just (Maybe Int -> Doc [a] -> [a]
    forall a. HasChars a => Maybe Int -> Doc a -> a
    DL.render Maybe Int
    forall a. Maybe a
    Nothing Doc [a]
    x)
      fromVal Val [a]
    _             = Maybe [a]
    forall a. Maybe a
    Nothing

    instance FromContext a b => FromContext a [b] where
      fromVal :: Val a -> Maybe [b]
    fromVal (ListVal  [Val a]
    xs) = (Val a -> Maybe b) -> [Val a] -> Maybe [b]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
    mapM Val a -> Maybe b
    forall a b. FromContext a b => Val a -> Maybe b
    fromVal [Val a]
    xs
      fromVal Val a
    x             = [Maybe b] -> Maybe [b]
    forall (t :: * -> *) (m :: * -> *) a.
    (Traversable t, Monad m) =>
    t (m a) -> m (t a)
    forall (m :: * -> *) a. Monad m => [m a] -> m [a]
    sequence [Val a -> Maybe b
    forall a b. FromContext a b => Val a -> Maybe b
    fromVal Val a
    x]

    instance TemplateTarget a => FromJSON (Val a) where
      parseJSON :: Value -> Parser (Val a)
    parseJSON Value
    v =
        case Value
    v of
          Array Array
    vec   -> [Val a] -> Val a
    forall a. [Val a] -> Val a
    ListVal ([Val a] -> Val a) -> Parser [Val a] -> Parser (Val a)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Value -> Parser (Val a)) -> [Value] -> Parser [Val a]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
    mapM Value -> Parser (Val a)
    forall a. FromJSON a => Value -> Parser a
    parseJSON (Array -> [Value]
    forall a. Vector a -> [a]
    V.toList Array
    vec)
          String Text
    t    -> Val a -> Parser (Val a)
    forall a. a -> Parser a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Val a -> Parser (Val a)) -> Val a -> Parser (Val a)
    forall a b. (a -> b) -> a -> b
    $ Doc a -> Val a
    forall a. Doc a -> Val a
    SimpleVal (Doc a -> Val a) -> Doc a -> Val a
    forall a b. (a -> b) -> a -> b
    $ a -> Doc a
    forall a. HasChars a => a -> Doc a
    DL.literal (a -> Doc a) -> a -> Doc a
    forall a b. (a -> b) -> a -> b
    $ Text -> a
    forall a. FromText a => Text -> a
    fromText Text
    t
          Number Scientific
    n    -> Val a -> Parser (Val a)
    forall a. a -> Parser a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Val a -> Parser (Val a)) -> Val a -> Parser (Val a)
    forall a b. (a -> b) -> a -> b
    $ Doc a -> Val a
    forall a. Doc a -> Val a
    SimpleVal (Doc a -> Val a) -> Doc a -> Val a
    forall a b. (a -> b) -> a -> b
    $ String -> Doc a
    forall a. IsString a => String -> a
    fromString (String -> Doc a) -> String -> Doc a
    forall a b. (a -> b) -> a -> b
    $
                                  case Scientific -> Either Double Integer
    forall r i. (RealFloat r, Integral i) => Scientific -> Either r i
    floatingOrInteger Scientific
    n of
                                      Left (Double
    r :: Double)   -> Double -> String
    forall a. Show a => a -> String
    show Double
    r
                                      Right (Integer
    i :: Integer) -> Integer -> String
    forall a. Show a => a -> String
    show Integer
    i
          Bool Bool
    b      -> Val a -> Parser (Val a)
    forall a. a -> Parser a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Val a -> Parser (Val a)) -> Val a -> Parser (Val a)
    forall a b. (a -> b) -> a -> b
    $ Bool -> Val a
    forall a. Bool -> Val a
    BoolVal Bool
    b
          Object Object
    _    -> Context a -> Val a
    forall a. Context a -> Val a
    MapVal (Context a -> Val a)
    -> (Map Text (Val a) -> Context a) -> Map Text (Val a) -> Val a
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Map Text (Val a) -> Context a
    forall a. Map Text (Val a) -> Context a
    Context (Map Text (Val a) -> Val a)
    -> Parser (Map Text (Val a)) -> Parser (Val a)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Value -> Parser (Map Text (Val a))
    forall a. FromJSON a => Value -> Parser a
    parseJSON Value
    v
          Value
    _           -> Val a -> Parser (Val a)
    forall a. a -> Parser a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Val a
    forall a. Val a
    NullVal

    instance TemplateTarget a => FromJSON (Context a) where
      parseJSON :: Value -> Parser (Context a)
    parseJSON Value
    v = do
        val <- Value -> Parser (Val a)
    forall a. FromJSON a => Value -> Parser a
    parseJSON Value
    v
        case val of
          MapVal Context a
    o -> Context a -> Parser (Context a)
    forall a. a -> Parser a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Context a
    o
          Val a
    _        -> String -> Parser (Context a)
    forall a. String -> Parser a
    forall (m :: * -> *) a. MonadFail m => String -> m a
    fail String
    "Expecting MapVal"

    instance TemplateTarget a => ToJSON (Context a) where
      toJSON :: Context a -> Value
    toJSON (Context Map Text (Val a)
    m) = Map Text (Val a) -> Value
    forall a. ToJSON a => a -> Value
    toJSON Map Text (Val a)
    m

    instance TemplateTarget a => ToJSON (Val a) where
      toJSON :: Val a -> Value
    toJSON Val a
    NullVal = Value
    Null
      toJSON (MapVal Context a
    m) = Context a -> Value
    forall a. ToJSON a => a -> Value
    toJSON Context a
    m
      toJSON (ListVal [Val a]
    xs) = [Val a] -> Value
    forall a. ToJSON a => a -> Value
    toJSON [Val a]
    xs
      toJSON (SimpleVal Doc a
    d) = Text -> Value
    forall a. ToJSON a => a -> Value
    toJSON (Text -> Value) -> Text -> Value
    forall a b. (a -> b) -> a -> b
    $ a -> Text
    forall a. ToText a => a -> Text
    toText (a -> Text) -> a -> Text
    forall a b. (a -> b) -> a -> b
    $ Maybe Int -> Doc a -> a
    forall a. HasChars a => Maybe Int -> Doc a -> a
    DL.render Maybe Int
    forall a. Maybe a
    Nothing Doc a
    d
      toJSON (BoolVal Bool
    b) = Bool -> Value
    forall a. ToJSON a => a -> Value
    toJSON Bool
    b

    mapDoc :: TemplateTarget a => (Doc a -> Doc a) -> Val a -> Val a
    mapDoc :: forall a. TemplateTarget a => (Doc a -> Doc a) -> Val a -> Val a
    mapDoc Doc a -> Doc a
    f Val a
    val =
      case Val a
    val of
        SimpleVal Doc a
    d        -> Doc a -> Val a
    forall a. Doc a -> Val a
    SimpleVal (Doc a -> Doc a
    f Doc a
    d)
        MapVal (Context Map Text (Val a)
    m) -> Context a -> Val a
    forall a. Context a -> Val a
    MapVal (Map Text (Val a) -> Context a
    forall a. Map Text (Val a) -> Context a
    Context (Map Text (Val a) -> Context a) -> Map Text (Val a) -> Context a
    forall a b. (a -> b) -> a -> b
    $ (Val a -> Val a) -> Map Text (Val a) -> Map Text (Val a)
    forall a b k. (a -> b) -> Map k a -> Map k b
    M.map ((Doc a -> Doc a) -> Val a -> Val a
    forall a. TemplateTarget a => (Doc a -> Doc a) -> Val a -> Val a
    mapDoc Doc a -> Doc a
    f) Map Text (Val a)
    m)
        ListVal [Val a]
    xs         -> [Val a] -> Val a
    forall a. [Val a] -> Val a
    ListVal ([Val a] -> Val a) -> [Val a] -> Val a
    forall a b. (a -> b) -> a -> b
    $ (Val a -> Val a) -> [Val a] -> [Val a]
    forall a b. (a -> b) -> [a] -> [b]
    map ((Doc a -> Doc a) -> Val a -> Val a
    forall a. TemplateTarget a => (Doc a -> Doc a) -> Val a -> Val a
    mapDoc Doc a -> Doc a
    f) [Val a]
    xs
        BoolVal Bool
    b          -> Bool -> Val a
    forall a. Bool -> Val a
    BoolVal Bool
    b
        Val a
    NullVal            -> Val a
    forall a. Val a
    NullVal

    mapText :: TemplateTarget a => (Text -> Text) -> Val a -> Val a
    mapText :: forall a. TemplateTarget a => (Text -> Text) -> Val a -> Val a
    mapText Text -> Text
    f Val a
    val =
      Identity (Val a) -> Val a
    forall a. Identity a -> a
    runIdentity ((a -> Identity a) -> Val a -> Identity (Val a)
    forall (t :: * -> *) (f :: * -> *) a b.
    (Traversable t, Applicative f) =>
    (a -> f b) -> t a -> f (t b)
    forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> Val a -> f (Val b)
    traverse (a -> Identity a
    forall a. a -> Identity a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (a -> Identity a) -> (a -> a) -> a -> Identity a
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> a
    forall a. FromText a => Text -> a
    fromText (Text -> a) -> (a -> Text) -> a -> a
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> Text
    f (Text -> Text) -> (a -> Text) -> a -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . a -> Text
    forall a. ToText a => a -> Text
    toText) Val a
    val)

    applyPipe :: TemplateTarget a => Pipe -> Val a -> Val a
    applyPipe :: forall a. TemplateTarget a => Pipe -> Val a -> Val a
    applyPipe Pipe
    ToLength Val a
    val = Doc a -> Val a
    forall a. Doc a -> Val a
    SimpleVal (Doc a -> Val a) -> Doc a -> Val a
    forall a b. (a -> b) -> a -> b
    $ String -> Doc a
    forall a. IsString a => String -> a
    fromString (String -> Doc a) -> (Int -> String) -> Int -> Doc a
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Int -> String
    forall a. Show a => a -> String
    show (Int -> Doc a) -> Int -> Doc a
    forall a b. (a -> b) -> a -> b
    $ Int
    len
      where
       len :: Int
    len = case Val a
    val of
               SimpleVal Doc a
    d        -> Text -> Int
    T.length (Text -> Int) -> (a -> Text) -> a -> Int
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . a -> Text
    forall a. ToText a => a -> Text
    toText (a -> Int) -> a -> Int
    forall a b. (a -> b) -> a -> b
    $ Maybe Int -> Doc a -> a
    forall a. HasChars a => Maybe Int -> Doc a -> a
    DL.render Maybe Int
    forall a. Maybe a
    Nothing Doc a
    d
               MapVal (Context Map Text (Val a)
    m) -> Map Text (Val a) -> Int
    forall k a. Map k a -> Int
    M.size Map Text (Val a)
    m
               ListVal [Val a]
    xs         -> [Val a] -> Int
    forall a. [a] -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length [Val a]
    xs
               BoolVal Bool
    _          -> Int
    0
               Val a
    NullVal            -> Int
    0
    applyPipe Pipe
    ToUppercase Val a
    val = (Text -> Text) -> Val a -> Val a
    forall a. TemplateTarget a => (Text -> Text) -> Val a -> Val a
    mapText Text -> Text
    T.toUpper Val a
    val
    applyPipe Pipe
    ToLowercase Val a
    val = (Text -> Text) -> Val a -> Val a
    forall a. TemplateTarget a => (Text -> Text) -> Val a -> Val a
    mapText Text -> Text
    T.toLower Val a
    val
    applyPipe Pipe
    ToPairs Val a
    val =
      case Val a
    val of
        MapVal (Context Map Text (Val a)
    m) ->
          [Val a] -> Val a
    forall a. [Val a] -> Val a
    ListVal ([Val a] -> Val a) -> [Val a] -> Val a
    forall a b. (a -> b) -> a -> b
    $ ((Text, Val a) -> Val a) -> [(Text, Val a)] -> [Val a]
    forall a b. (a -> b) -> [a] -> [b]
    map (Text, Val a) -> Val a
    forall {a}. HasChars a => (Text, Val a) -> Val a
    toPair ([(Text, Val a)] -> [Val a]) -> [(Text, Val a)] -> [Val a]
    forall a b. (a -> b) -> a -> b
    $ Map Text (Val a) -> [(Text, Val a)]
    forall k a. Map k a -> [(k, a)]
    M.toList Map Text (Val a)
    m
        ListVal [Val a]
    xs         ->
          [Val a] -> Val a
    forall a. [Val a] -> Val a
    ListVal ([Val a] -> Val a) -> [Val a] -> Val a
    forall a b. (a -> b) -> a -> b
    $ ((Text, Val a) -> Val a) -> [(Text, Val a)] -> [Val a]
    forall a b. (a -> b) -> [a] -> [b]
    map (Text, Val a) -> Val a
    forall {a}. HasChars a => (Text, Val a) -> Val a
    toPair ([(Text, Val a)] -> [Val a]) -> [(Text, Val a)] -> [Val a]
    forall a b. (a -> b) -> a -> b
    $ [Text] -> [Val a] -> [(Text, Val a)]
    forall a b. [a] -> [b] -> [(a, b)]
    zip ((Int -> Text) -> [Int] -> [Text]
    forall a b. (a -> b) -> [a] -> [b]
    map (String -> Text
    forall a. IsString a => String -> a
    fromString (String -> Text) -> (Int -> String) -> Int -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Int -> String
    forall a. Show a => a -> String
    show) [(Int
    1::Int)..]) [Val a]
    xs
        Val a
    _                  -> Val a
    val
     where
      toPair :: (Text, Val a) -> Val a
    toPair (Text
    k, Val a
    v) = Context a -> Val a
    forall a. Context a -> Val a
    MapVal (Context a -> Val a) -> Context a -> Val a
    forall a b. (a -> b) -> a -> b
    $ Map Text (Val a) -> Context a
    forall a. Map Text (Val a) -> Context a
    Context (Map Text (Val a) -> Context a) -> Map Text (Val a) -> Context a
    forall a b. (a -> b) -> a -> b
    $ [(Text, Val a)] -> Map Text (Val a)
    forall k a. Ord k => [(k, a)] -> Map k a
    M.fromList
                        [ (Text
    "key", Doc a -> Val a
    forall a. Doc a -> Val a
    SimpleVal (Doc a -> Val a) -> Doc a -> Val a
    forall a b. (a -> b) -> a -> b
    $ String -> Doc a
    forall a. IsString a => String -> a
    fromString (String -> Doc a) -> (Text -> String) -> Text -> Doc a
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> String
    T.unpack (Text -> Doc a) -> Text -> Doc a
    forall a b. (a -> b) -> a -> b
    $ Text
    k)
                        , (Text
    "value", Val a
    v) ]
    applyPipe Pipe
    FirstItem Val a
    val =
      case Val a
    val of
        ListVal (Val a
    x:[Val a]
    _) -> Val a
    x
        Val a
    _             -> Val a
    val
    applyPipe Pipe
    LastItem Val a
    val =
      case Val a
    val of
        ListVal xs :: [Val a]
    xs@(Val a
    _:[Val a]
    _) -> [Val a] -> Val a
    forall a. HasCallStack => [a] -> a
    last [Val a]
    xs
        Val a
    _                -> Val a
    val
    applyPipe Pipe
    Rest Val a
    val =
      case Val a
    val of
        ListVal (Val a
    _:[Val a]
    xs) -> [Val a] -> Val a
    forall a. [Val a] -> Val a
    ListVal [Val a]
    xs
        Val a
    _              -> Val a
    val
    applyPipe Pipe
    AllButLast Val a
    val =
      case Val a
    val of
        ListVal xs :: [Val a]
    xs@(Val a
    _:[Val a]
    _) -> [Val a] -> Val a
    forall a. [Val a] -> Val a
    ListVal ([Val a] -> [Val a]
    forall a. HasCallStack => [a] -> [a]
    init [Val a]
    xs)
        Val a
    _                -> Val a
    val
    applyPipe Pipe
    Reverse Val a
    val =
      case Val a
    val of
        ListVal [Val a]
    xs  -> [Val a] -> Val a
    forall a. [Val a] -> Val a
    ListVal ([Val a] -> [Val a]
    forall a. [a] -> [a]
    reverse [Val a]
    xs)
        SimpleVal{} -> (Text -> Text) -> Val a -> Val a
    forall a. TemplateTarget a => (Text -> Text) -> Val a -> Val a
    mapText Text -> Text
    T.reverse Val a
    val
        Val a
    _           -> Val a
    val
    applyPipe Pipe
    Chomp Val a
    val = (Doc a -> Doc a) -> Val a -> Val a
    forall a. TemplateTarget a => (Doc a -> Doc a) -> Val a -> Val a
    mapDoc Doc a -> Doc a
    forall a. Doc a -> Doc a
    DL.chomp Val a
    val
    applyPipe Pipe
    ToAlpha Val a
    val = (Text -> Text) -> Val a -> Val a
    forall a. TemplateTarget a => (Text -> Text) -> Val a -> Val a
    mapText Text -> Text
    toAlpha Val a
    val
      where toAlpha :: Text -> Text
    toAlpha Text
    t =
              case Reader Int
    forall a. Integral a => Reader a
    T.decimal Text
    t of
                Right (Int
    y,Text
    "") -> String -> Text
    forall a. IsString a => String -> a
    fromString [Int -> Char
    chr (Char -> Int
    ord Char
    'a' Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + (Int
    y Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    `mod` Int
    26) Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    1)]
                Either String (Int, Text)
    _            -> Text
    t
    applyPipe Pipe
    ToRoman Val a
    val = (Text -> Text) -> Val a -> Val a
    forall a. TemplateTarget a => (Text -> Text) -> Val a -> Val a
    mapText Text -> Text
    toRoman' Val a
    val
      where toRoman' :: Text -> Text
    toRoman' Text
    t =
             case Reader Int
    forall a. Integral a => Reader a
    T.decimal Text
    t of
               Right (Int
    y,Text
    "") -> Text -> Maybe Text -> Text
    forall a. a -> Maybe a -> a
    fromMaybe Text
    t (Int -> Maybe Text
    toRoman Int
    y)
               Either String (Int, Text)
    _            -> Text
    t
    applyPipe Pipe
    NoWrap Val a
    val = (Doc a -> Doc a) -> Val a -> Val a
    forall a. TemplateTarget a => (Doc a -> Doc a) -> Val a -> Val a
    mapDoc Doc a -> Doc a
    forall a. IsString a => Doc a -> Doc a
    DL.nowrap Val a
    val
    applyPipe (Block Alignment
    align Int
    n Border
    border) Val a
    val =
      let constructor :: Int -> Doc a -> Doc a
    constructor = case Alignment
    align of
                          Alignment
    LeftAligned  -> Int -> Doc a -> Doc a
    forall a. HasChars a => Int -> Doc a -> Doc a
    DL.lblock
                          Alignment
    Centered     -> Int -> Doc a -> Doc a
    forall a. HasChars a => Int -> Doc a -> Doc a
    DL.cblock
                          Alignment
    RightAligned -> Int -> Doc a -> Doc a
    forall a. HasChars a => Int -> Doc a -> Doc a
    DL.rblock
          toBorder :: Text -> Doc a
    toBorder Text
    y = if Text -> Bool
    T.null Text
    y
                          then Doc a
    forall a. Monoid a => a
    mempty
                          else a -> Doc a
    forall a. HasChars a => a -> Doc a
    DL.vfill (Text -> a
    forall a. FromText a => Text -> a
    fromText Text
    y)
      in case Val a -> Val a
    forall a. Monoid a => Val a -> Val a
    nullToSimple Val a
    val of
           SimpleVal Doc a
    d -> Doc a -> Val a
    forall a. Doc a -> Val a
    SimpleVal (Doc a -> Val a) -> Doc a -> Val a
    forall a b. (a -> b) -> a -> b
    $
                            Text -> Doc a
    forall {a}. (HasChars a, FromText a) => Text -> Doc a
    toBorder (Border -> Text
    borderLeft Border
    border) Doc a -> Doc a -> Doc a
    forall a. Semigroup a => a -> a -> a
    <>
                            Int -> Doc a -> Doc a
    constructor Int
    n Doc a
    d Doc a -> Doc a -> Doc a
    forall a. Semigroup a => a -> a -> a
    <>
                            Text -> Doc a
    forall {a}. (HasChars a, FromText a) => Text -> Doc a
    toBorder (Border -> Text
    borderRight Border
    border)
           Val a
    _           -> Val a
    val

    nullToSimple :: Monoid a => Val a -> Val a
    nullToSimple :: forall a. Monoid a => Val a -> Val a
    nullToSimple Val a
    NullVal = Doc a -> Val a
    forall a. Doc a -> Val a
    SimpleVal Doc a
    forall a. Monoid a => a
    mempty
    nullToSimple Val a
    x = Val a
    x

    -- | Convert number 0 < x < 4000 to lowercase roman numeral.
    toRoman :: Int -> Maybe Text
    toRoman :: Int -> Maybe Text
    toRoman Int
    x
      | Int
    x Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Int
    1000
      , Int
    x Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    < Int
    4000  = (Text
    "m" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <>) (Text -> Text) -> Maybe Text -> Maybe Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Int -> Maybe Text
    toRoman (Int
    x Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    1000)
      | Int
    x Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Int
    900  = (Text
    "cm" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <>) (Text -> Text) -> Maybe Text -> Maybe Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Int -> Maybe Text
    toRoman (Int
    x Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    900)
      | Int
    x Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Int
    500  = (Text
    "d" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <>) (Text -> Text) -> Maybe Text -> Maybe Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Int -> Maybe Text
    toRoman (Int
    x Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    500)
      | Int
    x Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Int
    400  = (Text
    "cd" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <>) (Text -> Text) -> Maybe Text -> Maybe Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Int -> Maybe Text
    toRoman (Int
    x Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    400)
      | Int
    x Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Int
    100  = (Text
    "c" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <>) (Text -> Text) -> Maybe Text -> Maybe Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Int -> Maybe Text
    toRoman (Int
    x Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    100)
      | Int
    x Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Int
    90   = (Text
    "xc" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <>) (Text -> Text) -> Maybe Text -> Maybe Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Int -> Maybe Text
    toRoman (Int
    x Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    90)
      | Int
    x Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Int
    50   = (Text
    "l" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <>) (Text -> Text) -> Maybe Text -> Maybe Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Int -> Maybe Text
    toRoman (Int
    x Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    50)
      | Int
    x Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Int
    40   = (Text
    "xl" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <>) (Text -> Text) -> Maybe Text -> Maybe Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Int -> Maybe Text
    toRoman (Int
    x Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    40)
      | Int
    x Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Int
    10   = (Text
    "x" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <>) (Text -> Text) -> Maybe Text -> Maybe Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Int -> Maybe Text
    toRoman (Int
    x Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    10)
      | Int
    x Int -> Int -> Bool
    forall a. Eq a => a -> a -> Bool
    == Int
    9    = Text -> Maybe Text
    forall a. a -> Maybe a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Text
    "ix"
      | Int
    x Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Int
    5    = (Text
    "v" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <>) (Text -> Text) -> Maybe Text -> Maybe Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Int -> Maybe Text
    toRoman (Int
    x Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    5)
      | Int
    x Int -> Int -> Bool
    forall a. Eq a => a -> a -> Bool
    == Int
    4    = Text -> Maybe Text
    forall a. a -> Maybe a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Text
    "iv"
      | Int
    x Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Int
    1    = (Text
    "i" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <>) (Text -> Text) -> Maybe Text -> Maybe Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Int -> Maybe Text
    toRoman (Int
    x Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    1)
      | Int
    x Int -> Int -> Bool
    forall a. Eq a => a -> a -> Bool
    == Int
    0    = Text -> Maybe Text
    forall a. a -> Maybe a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Text
    ""
      | Bool
    otherwise = Maybe Text
    forall a. Maybe a
    Nothing

    applyPipes :: TemplateTarget a => [Pipe] -> Val a -> Val a
    applyPipes :: forall a. TemplateTarget a => [Pipe] -> Val a -> Val a
    applyPipes [Pipe]
    fs Val a
    x = (Pipe -> Val a -> Val a) -> Val a -> [Pipe] -> Val a
    forall a b. (a -> b -> b) -> b -> [a] -> b
    forall (t :: * -> *) a b.
    Foldable t =>
    (a -> b -> b) -> b -> t a -> b
    foldr Pipe -> Val a -> Val a
    forall a. TemplateTarget a => Pipe -> Val a -> Val a
    applyPipe Val a
    x ([Pipe] -> Val a) -> [Pipe] -> Val a
    forall a b. (a -> b) -> a -> b
    $ [Pipe] -> [Pipe]
    forall a. [a] -> [a]
    reverse [Pipe]
    fs

    multiLookup :: TemplateTarget a => [Text] -> Val a -> Val a
    multiLookup :: forall a. TemplateTarget a => [Text] -> Val a -> Val a
    multiLookup [] Val a
    x = Val a
    x
    multiLookup (Text
    t:[Text]
    vs) (MapVal (Context Map Text (Val a)
    o)) =
      case Text -> Map Text (Val a) -> Maybe (Val a)
    forall k a. Ord k => k -> Map k a -> Maybe a
    M.lookup Text
    t Map Text (Val a)
    o of
        Maybe (Val a)
    Nothing -> Val a
    forall a. Val a
    NullVal
        Just Val a
    v' -> [Text] -> Val a -> Val a
    forall a. TemplateTarget a => [Text] -> Val a -> Val a
    multiLookup [Text]
    vs Val a
    v'
    multiLookup [Text]
    _ Val a
    _ = Val a
    forall a. Val a
    NullVal

    -- The Bool indicates whether it's a true or false value.
    data Resolved a = Resolved Bool [Doc a]
       deriving (Int -> Resolved a -> ShowS
    [Resolved a] -> ShowS
    Resolved a -> String
    (Int -> Resolved a -> ShowS)
    -> (Resolved a -> String)
    -> ([Resolved a] -> ShowS)
    -> Show (Resolved a)
    forall a. Show a => Int -> Resolved a -> ShowS
    forall a. Show a => [Resolved a] -> ShowS
    forall a. Show a => Resolved a -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: forall a. Show a => Int -> Resolved a -> ShowS
    showsPrec :: Int -> Resolved a -> ShowS
    $cshow :: forall a. Show a => Resolved a -> String
    show :: Resolved a -> String
    $cshowList :: forall a. Show a => [Resolved a] -> ShowS
    showList :: [Resolved a] -> ShowS
    Show, ReadPrec [Resolved a]
    ReadPrec (Resolved a)
    Int -> ReadS (Resolved a)
    ReadS [Resolved a]
    (Int -> ReadS (Resolved a))
    -> ReadS [Resolved a]
    -> ReadPrec (Resolved a)
    -> ReadPrec [Resolved a]
    -> Read (Resolved a)
    forall a. Read a => ReadPrec [Resolved a]
    forall a. Read a => ReadPrec (Resolved a)
    forall a. Read a => Int -> ReadS (Resolved a)
    forall a. Read a => ReadS [Resolved a]
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: forall a. Read a => Int -> ReadS (Resolved a)
    readsPrec :: Int -> ReadS (Resolved a)
    $creadList :: forall a. Read a => ReadS [Resolved a]
    readList :: ReadS [Resolved a]
    $creadPrec :: forall a. Read a => ReadPrec (Resolved a)
    readPrec :: ReadPrec (Resolved a)
    $creadListPrec :: forall a. Read a => ReadPrec [Resolved a]
    readListPrec :: ReadPrec [Resolved a]
    Read, Typeable (Resolved a)
    Typeable (Resolved a) =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> Resolved a -> c (Resolved a))
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c (Resolved a))
    -> (Resolved a -> Constr)
    -> (Resolved a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c (Resolved a)))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e))
        -> Maybe (c (Resolved a)))
    -> ((forall b. Data b => b -> b) -> Resolved a -> Resolved a)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> Resolved a -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> Resolved a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> Resolved a -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> Resolved a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> Resolved a -> m (Resolved a))
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Resolved a -> m (Resolved a))
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Resolved a -> m (Resolved a))
    -> Data (Resolved a)
    Resolved a -> Constr
    Resolved a -> DataType
    (forall b. Data b => b -> b) -> Resolved a -> Resolved a
    forall a. Data a => Typeable (Resolved a)
    forall a. Data a => Resolved a -> Constr
    forall a. Data a => Resolved a -> DataType
    forall a.
    Data a =>
    (forall b. Data b => b -> b) -> Resolved a -> Resolved a
    forall a u.
    Data a =>
    Int -> (forall d. Data d => d -> u) -> Resolved a -> u
    forall a u.
    Data a =>
    (forall d. Data d => d -> u) -> Resolved a -> [u]
    forall a r r'.
    Data a =>
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Resolved a -> r
    forall a r r'.
    Data a =>
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Resolved a -> r
    forall a (m :: * -> *).
    (Data a, Monad m) =>
    (forall d. Data d => d -> m d) -> Resolved a -> m (Resolved a)
    forall a (m :: * -> *).
    (Data a, MonadPlus m) =>
    (forall d. Data d => d -> m d) -> Resolved a -> m (Resolved a)
    forall a (c :: * -> *).
    Data a =>
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Resolved a)
    forall a (c :: * -> *).
    Data a =>
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Resolved a -> c (Resolved a)
    forall a (t :: * -> *) (c :: * -> *).
    (Data a, Typeable t) =>
    (forall d. Data d => c (t d)) -> Maybe (c (Resolved a))
    forall a (t :: * -> * -> *) (c :: * -> *).
    (Data a, Typeable t) =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (Resolved a))
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> Resolved a -> u
    forall u. (forall d. Data d => d -> u) -> Resolved a -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Resolved a -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Resolved a -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Resolved a -> m (Resolved a)
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Resolved a -> m (Resolved a)
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Resolved a)
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Resolved a -> c (Resolved a)
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Resolved a))
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (Resolved a))
    $cgfoldl :: forall a (c :: * -> *).
    Data a =>
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Resolved a -> c (Resolved a)
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Resolved a -> c (Resolved a)
    $cgunfold :: forall a (c :: * -> *).
    Data a =>
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Resolved a)
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Resolved a)
    $ctoConstr :: forall a. Data a => Resolved a -> Constr
    toConstr :: Resolved a -> Constr
    $cdataTypeOf :: forall a. Data a => Resolved a -> DataType
    dataTypeOf :: Resolved a -> DataType
    $cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
    (Data a, Typeable t) =>
    (forall d. Data d => c (t d)) -> Maybe (c (Resolved a))
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Resolved a))
    $cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
    (Data a, Typeable t) =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (Resolved a))
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (Resolved a))
    $cgmapT :: forall a.
    Data a =>
    (forall b. Data b => b -> b) -> Resolved a -> Resolved a
    gmapT :: (forall b. Data b => b -> b) -> Resolved a -> Resolved a
    $cgmapQl :: forall a r r'.
    Data a =>
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Resolved a -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Resolved a -> r
    $cgmapQr :: forall a r r'.
    Data a =>
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Resolved a -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Resolved a -> r
    $cgmapQ :: forall a u.
    Data a =>
    (forall d. Data d => d -> u) -> Resolved a -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> Resolved a -> [u]
    $cgmapQi :: forall a u.
    Data a =>
    Int -> (forall d. Data d => d -> u) -> Resolved a -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Resolved a -> u
    $cgmapM :: forall a (m :: * -> *).
    (Data a, Monad m) =>
    (forall d. Data d => d -> m d) -> Resolved a -> m (Resolved a)
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Resolved a -> m (Resolved a)
    $cgmapMp :: forall a (m :: * -> *).
    (Data a, MonadPlus m) =>
    (forall d. Data d => d -> m d) -> Resolved a -> m (Resolved a)
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Resolved a -> m (Resolved a)
    $cgmapMo :: forall a (m :: * -> *).
    (Data a, MonadPlus m) =>
    (forall d. Data d => d -> m d) -> Resolved a -> m (Resolved a)
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Resolved a -> m (Resolved a)
    Data, Typeable, (forall x. Resolved a -> Rep (Resolved a) x)
    -> (forall x. Rep (Resolved a) x -> Resolved a)
    -> Generic (Resolved a)
    forall x. Rep (Resolved a) x -> Resolved a
    forall x. Resolved a -> Rep (Resolved a) x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    forall a x. Rep (Resolved a) x -> Resolved a
    forall a x. Resolved a -> Rep (Resolved a) x
    $cfrom :: forall a x. Resolved a -> Rep (Resolved a) x
    from :: forall x. Resolved a -> Rep (Resolved a) x
    $cto :: forall a x. Rep (Resolved a) x -> Resolved a
    to :: forall x. Rep (Resolved a) x -> Resolved a
    Generic, Resolved a -> Resolved a -> Bool
    (Resolved a -> Resolved a -> Bool)
    -> (Resolved a -> Resolved a -> Bool) -> Eq (Resolved a)
    forall a. Eq a => Resolved a -> Resolved a -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: forall a. Eq a => Resolved a -> Resolved a -> Bool
    == :: Resolved a -> Resolved a -> Bool
    $c/= :: forall a. Eq a => Resolved a -> Resolved a -> Bool
    /= :: Resolved a -> Resolved a -> Bool
    Eq, Eq (Resolved a)
    Eq (Resolved a) =>
    (Resolved a -> Resolved a -> Ordering)
    -> (Resolved a -> Resolved a -> Bool)
    -> (Resolved a -> Resolved a -> Bool)
    -> (Resolved a -> Resolved a -> Bool)
    -> (Resolved a -> Resolved a -> Bool)
    -> (Resolved a -> Resolved a -> Resolved a)
    -> (Resolved a -> Resolved a -> Resolved a)
    -> Ord (Resolved a)
    Resolved a -> Resolved a -> Bool
    Resolved a -> Resolved a -> Ordering
    Resolved a -> Resolved a -> Resolved a
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    forall a. Ord a => Eq (Resolved a)
    forall a. Ord a => Resolved a -> Resolved a -> Bool
    forall a. Ord a => Resolved a -> Resolved a -> Ordering
    forall a. Ord a => Resolved a -> Resolved a -> Resolved a
    $ccompare :: forall a. Ord a => Resolved a -> Resolved a -> Ordering
    compare :: Resolved a -> Resolved a -> Ordering
    $c< :: forall a. Ord a => Resolved a -> Resolved a -> Bool
    < :: Resolved a -> Resolved a -> Bool
    $c<= :: forall a. Ord a => Resolved a -> Resolved a -> Bool
    <= :: Resolved a -> Resolved a -> Bool
    $c> :: forall a. Ord a => Resolved a -> Resolved a -> Bool
    > :: Resolved a -> Resolved a -> Bool
    $c>= :: forall a. Ord a => Resolved a -> Resolved a -> Bool
    >= :: Resolved a -> Resolved a -> Bool
    $cmax :: forall a. Ord a => Resolved a -> Resolved a -> Resolved a
    max :: Resolved a -> Resolved a -> Resolved a
    $cmin :: forall a. Ord a => Resolved a -> Resolved a -> Resolved a
    min :: Resolved a -> Resolved a -> Resolved a
    Ord,
                 (forall m. Monoid m => Resolved m -> m)
    -> (forall m a. Monoid m => (a -> m) -> Resolved a -> m)
    -> (forall m a. Monoid m => (a -> m) -> Resolved a -> m)
    -> (forall a b. (a -> b -> b) -> b -> Resolved a -> b)
    -> (forall a b. (a -> b -> b) -> b -> Resolved a -> b)
    -> (forall b a. (b -> a -> b) -> b -> Resolved a -> b)
    -> (forall b a. (b -> a -> b) -> b -> Resolved a -> b)
    -> (forall a. (a -> a -> a) -> Resolved a -> a)
    -> (forall a. (a -> a -> a) -> Resolved a -> a)
    -> (forall a. Resolved a -> [a])
    -> (forall a. Resolved a -> Bool)
    -> (forall a. Resolved a -> Int)
    -> (forall a. Eq a => a -> Resolved a -> Bool)
    -> (forall a. Ord a => Resolved a -> a)
    -> (forall a. Ord a => Resolved a -> a)
    -> (forall a. Num a => Resolved a -> a)
    -> (forall a. Num a => Resolved a -> a)
    -> Foldable Resolved
    forall a. Eq a => a -> Resolved a -> Bool
    forall a. Num a => Resolved a -> a
    forall a. Ord a => Resolved a -> a
    forall m. Monoid m => Resolved m -> m
    forall a. Resolved a -> Bool
    forall a. Resolved a -> Int
    forall a. Resolved a -> [a]
    forall a. (a -> a -> a) -> Resolved a -> a
    forall m a. Monoid m => (a -> m) -> Resolved a -> m
    forall b a. (b -> a -> b) -> b -> Resolved a -> b
    forall a b. (a -> b -> b) -> b -> Resolved a -> b
    forall (t :: * -> *).
    (forall m. Monoid m => t m -> m)
    -> (forall m a. Monoid m => (a -> m) -> t a -> m)
    -> (forall m a. Monoid m => (a -> m) -> t a -> m)
    -> (forall a b. (a -> b -> b) -> b -> t a -> b)
    -> (forall a b. (a -> b -> b) -> b -> t a -> b)
    -> (forall b a. (b -> a -> b) -> b -> t a -> b)
    -> (forall b a. (b -> a -> b) -> b -> t a -> b)
    -> (forall a. (a -> a -> a) -> t a -> a)
    -> (forall a. (a -> a -> a) -> t a -> a)
    -> (forall a. t a -> [a])
    -> (forall a. t a -> Bool)
    -> (forall a. t a -> Int)
    -> (forall a. Eq a => a -> t a -> Bool)
    -> (forall a. Ord a => t a -> a)
    -> (forall a. Ord a => t a -> a)
    -> (forall a. Num a => t a -> a)
    -> (forall a. Num a => t a -> a)
    -> Foldable t
    $cfold :: forall m. Monoid m => Resolved m -> m
    fold :: forall m. Monoid m => Resolved m -> m
    $cfoldMap :: forall m a. Monoid m => (a -> m) -> Resolved a -> m
    foldMap :: forall m a. Monoid m => (a -> m) -> Resolved a -> m
    $cfoldMap' :: forall m a. Monoid m => (a -> m) -> Resolved a -> m
    foldMap' :: forall m a. Monoid m => (a -> m) -> Resolved a -> m
    $cfoldr :: forall a b. (a -> b -> b) -> b -> Resolved a -> b
    foldr :: forall a b. (a -> b -> b) -> b -> Resolved a -> b
    $cfoldr' :: forall a b. (a -> b -> b) -> b -> Resolved a -> b
    foldr' :: forall a b. (a -> b -> b) -> b -> Resolved a -> b
    $cfoldl :: forall b a. (b -> a -> b) -> b -> Resolved a -> b
    foldl :: forall b a. (b -> a -> b) -> b -> Resolved a -> b
    $cfoldl' :: forall b a. (b -> a -> b) -> b -> Resolved a -> b
    foldl' :: forall b a. (b -> a -> b) -> b -> Resolved a -> b
    $cfoldr1 :: forall a. (a -> a -> a) -> Resolved a -> a
    foldr1 :: forall a. (a -> a -> a) -> Resolved a -> a
    $cfoldl1 :: forall a. (a -> a -> a) -> Resolved a -> a
    foldl1 :: forall a. (a -> a -> a) -> Resolved a -> a
    $ctoList :: forall a. Resolved a -> [a]
    toList :: forall a. Resolved a -> [a]
    $cnull :: forall a. Resolved a -> Bool
    null :: forall a. Resolved a -> Bool
    $clength :: forall a. Resolved a -> Int
    length :: forall a. Resolved a -> Int
    $celem :: forall a. Eq a => a -> Resolved a -> Bool
    elem :: forall a. Eq a => a -> Resolved a -> Bool
    $cmaximum :: forall a. Ord a => Resolved a -> a
    maximum :: forall a. Ord a => Resolved a -> a
    $cminimum :: forall a. Ord a => Resolved a -> a
    minimum :: forall a. Ord a => Resolved a -> a
    $csum :: forall a. Num a => Resolved a -> a
    sum :: forall a. Num a => Resolved a -> a
    $cproduct :: forall a. Num a => Resolved a -> a
    product :: forall a. Num a => Resolved a -> a
    Foldable, Functor Resolved
    Foldable Resolved
    (Functor Resolved, Foldable Resolved) =>
    (forall (f :: * -> *) a b.
     Applicative f =>
     (a -> f b) -> Resolved a -> f (Resolved b))
    -> (forall (f :: * -> *) a.
        Applicative f =>
        Resolved (f a) -> f (Resolved a))
    -> (forall (m :: * -> *) a b.
        Monad m =>
        (a -> m b) -> Resolved a -> m (Resolved b))
    -> (forall (m :: * -> *) a.
        Monad m =>
        Resolved (m a) -> m (Resolved a))
    -> Traversable Resolved
    forall (t :: * -> *).
    (Functor t, Foldable t) =>
    (forall (f :: * -> *) a b.
     Applicative f =>
     (a -> f b) -> t a -> f (t b))
    -> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
    -> (forall (m :: * -> *) a b.
        Monad m =>
        (a -> m b) -> t a -> m (t b))
    -> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
    -> Traversable t
    forall (m :: * -> *) a. Monad m => Resolved (m a) -> m (Resolved a)
    forall (f :: * -> *) a.
    Applicative f =>
    Resolved (f a) -> f (Resolved a)
    forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Resolved a -> m (Resolved b)
    forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> Resolved a -> f (Resolved b)
    $ctraverse :: forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> Resolved a -> f (Resolved b)
    traverse :: forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> Resolved a -> f (Resolved b)
    $csequenceA :: forall (f :: * -> *) a.
    Applicative f =>
    Resolved (f a) -> f (Resolved a)
    sequenceA :: forall (f :: * -> *) a.
    Applicative f =>
    Resolved (f a) -> f (Resolved a)
    $cmapM :: forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Resolved a -> m (Resolved b)
    mapM :: forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Resolved a -> m (Resolved b)
    $csequence :: forall (m :: * -> *) a. Monad m => Resolved (m a) -> m (Resolved a)
    sequence :: forall (m :: * -> *) a. Monad m => Resolved (m a) -> m (Resolved a)
    Traversable, (forall a b. (a -> b) -> Resolved a -> Resolved b)
    -> (forall a b. a -> Resolved b -> Resolved a) -> Functor Resolved
    forall a b. a -> Resolved b -> Resolved a
    forall a b. (a -> b) -> Resolved a -> Resolved b
    forall (f :: * -> *).
    (forall a b. (a -> b) -> f a -> f b)
    -> (forall a b. a -> f b -> f a) -> Functor f
    $cfmap :: forall a b. (a -> b) -> Resolved a -> Resolved b
    fmap :: forall a b. (a -> b) -> Resolved a -> Resolved b
    $c<$ :: forall a b. a -> Resolved b -> Resolved a
    <$ :: forall a b. a -> Resolved b -> Resolved a
    Functor)

    instance Semigroup (Resolved a) where
      Resolved Bool
    b1 [Doc a]
    x1 <> :: Resolved a -> Resolved a -> Resolved a
    <> Resolved Bool
    b2 [Doc a]
    x2 = Bool -> [Doc a] -> Resolved a
    forall a. Bool -> [Doc a] -> Resolved a
    Resolved (Bool
    b1 Bool -> Bool -> Bool
    || Bool
    b2) ([Doc a]
    x1 [Doc a] -> [Doc a] -> [Doc a]
    forall a. Semigroup a => a -> a -> a
    <> [Doc a]
    x2)

    instance Monoid (Resolved a) where
      mappend :: Resolved a -> Resolved a -> Resolved a
    mappend = Resolved a -> Resolved a -> Resolved a
    forall a. Semigroup a => a -> a -> a
    (<>)
      mempty :: Resolved a
    mempty = Bool -> [Doc a] -> Resolved a
    forall a. Bool -> [Doc a] -> Resolved a
    Resolved Bool
    False []

    resolveVariable :: TemplateTarget a
                    => Variable -> Context a -> Resolved a
    resolveVariable :: forall a. TemplateTarget a => Variable -> Context a -> Resolved a
    resolveVariable Variable
    v Context a
    ctx = Variable -> Val a -> Resolved a
    forall a. TemplateTarget a => Variable -> Val a -> Resolved a
    resolveVariable' Variable
    v (Context a -> Val a
    forall a. Context a -> Val a
    MapVal Context a
    ctx)

    resolveVariable' :: TemplateTarget a
                     => Variable -> Val a -> Resolved a
    resolveVariable' :: forall a. TemplateTarget a => Variable -> Val a -> Resolved a
    resolveVariable' Variable
    v Val a
    val =
      case [Pipe] -> Val a -> Val a
    forall a. TemplateTarget a => [Pipe] -> Val a -> Val a
    applyPipes (Variable -> [Pipe]
    varPipes Variable
    v) (Val a -> Val a) -> Val a -> Val a
    forall a b. (a -> b) -> a -> b
    $ [Text] -> Val a -> Val a
    forall a. TemplateTarget a => [Text] -> Val a -> Val a
    multiLookup (Variable -> [Text]
    varParts Variable
    v) Val a
    val of
        ListVal [Val a]
    xs    -> [Resolved a] -> Resolved a
    forall a. Monoid a => [a] -> a
    mconcat ([Resolved a] -> Resolved a) -> [Resolved a] -> Resolved a
    forall a b. (a -> b) -> a -> b
    $ (Val a -> Resolved a) -> [Val a] -> [Resolved a]
    forall a b. (a -> b) -> [a] -> [b]
    map (Variable -> Val a -> Resolved a
    forall a. TemplateTarget a => Variable -> Val a -> Resolved a
    resolveVariable' Variable
    forall a. Monoid a => a
    mempty) [Val a]
    xs
        SimpleVal Doc a
    d
          | Doc a -> Bool
    forall a. Doc a -> Bool
    DL.isEmpty Doc a
    d -> Bool -> [Doc a] -> Resolved a
    forall a. Bool -> [Doc a] -> Resolved a
    Resolved Bool
    False []
          | Bool
    otherwise    -> Bool -> [Doc a] -> Resolved a
    forall a. Bool -> [Doc a] -> Resolved a
    Resolved Bool
    True [Doc a -> Doc a
    forall a. Doc a -> Doc a
    removeFinalNl Doc a
    d]
        MapVal Context a
    _      -> Bool -> [Doc a] -> Resolved a
    forall a. Bool -> [Doc a] -> Resolved a
    Resolved Bool
    True [Doc a
    "true"]
        BoolVal Bool
    True  -> Bool -> [Doc a] -> Resolved a
    forall a. Bool -> [Doc a] -> Resolved a
    Resolved Bool
    True [Doc a
    "true"]
        BoolVal Bool
    False -> Bool -> [Doc a] -> Resolved a
    forall a. Bool -> [Doc a] -> Resolved a
    Resolved Bool
    False [Doc a
    "false"]
        Val a
    NullVal       -> Bool -> [Doc a] -> Resolved a
    forall a. Bool -> [Doc a] -> Resolved a
    Resolved Bool
    False []

    removeFinalNl :: Doc a -> Doc a
    removeFinalNl :: forall a. Doc a -> Doc a
    removeFinalNl Doc a
    DL.NewLine        = Doc a
    forall a. Monoid a => a
    mempty
    removeFinalNl Doc a
    DL.CarriageReturn = Doc a
    forall a. Monoid a => a
    mempty
    removeFinalNl (DL.Concat Doc a
    d1 Doc a
    d2) = Doc a
    d1 Doc a -> Doc a -> Doc a
    forall a. Semigroup a => a -> a -> a
    <> Doc a -> Doc a
    forall a. Doc a -> Doc a
    removeFinalNl Doc a
    d2
    removeFinalNl Doc a
    x                 = Doc a
    x

    withVariable :: (Monad m, TemplateTarget a)
                 => Variable -> Context a -> (Context a -> m (Doc a))
                 -> m [Doc a]
    withVariable :: forall (m :: * -> *) a.
    (Monad m, TemplateTarget a) =>
    Variable -> Context a -> (Context a -> m (Doc a)) -> m [Doc a]
    withVariable Variable
    var Context a
    ctx Context a -> m (Doc a)
    f =
      case [Pipe] -> Val a -> Val a
    forall a. TemplateTarget a => [Pipe] -> Val a -> Val a
    applyPipes (Variable -> [Pipe]
    varPipes Variable
    var) (Val a -> Val a) -> Val a -> Val a
    forall a b. (a -> b) -> a -> b
    $ [Text] -> Val a -> Val a
    forall a. TemplateTarget a => [Text] -> Val a -> Val a
    multiLookup (Variable -> [Text]
    varParts Variable
    var) (Context a -> Val a
    forall a. Context a -> Val a
    MapVal Context a
    ctx) of
        Val a
    NullVal     -> [Doc a] -> m [Doc a]
    forall a. a -> m a
    forall (m :: * -> *) a. Monad m => a -> m a
    return [Doc a]
    forall a. Monoid a => a
    mempty
        ListVal [Val a]
    xs  -> (Val a -> m (Doc a)) -> [Val a] -> m [Doc a]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
    mapM (\Val a
    iterval -> Context a -> m (Doc a)
    f (Context a -> m (Doc a)) -> Context a -> m (Doc a)
    forall a b. (a -> b) -> a -> b
    $ Val a -> Context a
    setVarVal Val a
    iterval) [Val a]
    xs
        MapVal Context a
    ctx' -> (Doc a -> [Doc a] -> [Doc a]
    forall a. a -> [a] -> [a]
    :[]) (Doc a -> [Doc a]) -> m (Doc a) -> m [Doc a]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Context a -> m (Doc a)
    f (Val a -> Context a
    setVarVal (Context a -> Val a
    forall a. Context a -> Val a
    MapVal Context a
    ctx'))
        Val a
    val' -> (Doc a -> [Doc a] -> [Doc a]
    forall a. a -> [a] -> [a]
    :[]) (Doc a -> [Doc a]) -> m (Doc a) -> m [Doc a]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Context a -> m (Doc a)
    f (Val a -> Context a
    setVarVal Val a
    val')
     where
      setVarVal :: Val a -> Context a
    setVarVal Val a
    x =
        Variable -> Val a -> Context a -> Context a
    forall {a}. Variable -> Val a -> Context a -> Context a
    addToContext Variable
    var Val a
    x (Context a -> Context a) -> Context a -> Context a
    forall a b. (a -> b) -> a -> b
    $ Map Text (Val a) -> Context a
    forall a. Map Text (Val a) -> Context a
    Context (Map Text (Val a) -> Context a) -> Map Text (Val a) -> Context a
    forall a b. (a -> b) -> a -> b
    $ Text -> Val a -> Map Text (Val a) -> Map Text (Val a)
    forall k a. Ord k => k -> a -> Map k a -> Map k a
    M.insert Text
    "it" Val a
    x (Map Text (Val a) -> Map Text (Val a))
    -> Map Text (Val a) -> Map Text (Val a)
    forall a b. (a -> b) -> a -> b
    $ Context a -> Map Text (Val a)
    forall a. Context a -> Map Text (Val a)
    unContext Context a
    ctx
      addToContext :: Variable -> Val a -> Context a -> Context a
    addToContext (Variable [] [Pipe]
    _) Val a
    _ (Context Map Text (Val a)
    ctx') = Map Text (Val a) -> Context a
    forall a. Map Text (Val a) -> Context a
    Context Map Text (Val a)
    ctx'
      addToContext (Variable (Text
    v:[Text]
    vs) [Pipe]
    fs) Val a
    x (Context Map Text (Val a)
    ctx') =
        Map Text (Val a) -> Context a
    forall a. Map Text (Val a) -> Context a
    Context (Map Text (Val a) -> Context a) -> Map Text (Val a) -> Context a
    forall a b. (a -> b) -> a -> b
    $ (Val a -> Val a) -> Text -> Map Text (Val a) -> Map Text (Val a)
    forall k a. Ord k => (a -> a) -> k -> Map k a -> Map k a
    M.adjust
                  (\Val a
    z -> case Val a
    z of
                           Val a
    _ | [Text] -> Bool
    forall a. [a] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null [Text]
    vs -> Val a
    x
                           MapVal Context a
    m    ->
                             Context a -> Val a
    forall a. Context a -> Val a
    MapVal (Context a -> Val a) -> Context a -> Val a
    forall a b. (a -> b) -> a -> b
    $ Variable -> Val a -> Context a -> Context a
    addToContext ([Text] -> [Pipe] -> Variable
    Variable [Text]
    vs [Pipe]
    fs) Val a
    x Context a
    m
                           Val a
    _ -> Val a
    z) Text
    v Map Text (Val a)
    ctx'

    type RenderState = S.State Int

    -- | Render a compiled template in a "context" which provides
    -- values for the template's variables.
    renderTemplate :: (TemplateTarget a, ToContext a b)
                   => Template a -> b -> Doc a
    renderTemplate :: forall a b.
    (TemplateTarget a, ToContext a b) =>
    Template a -> b -> Doc a
    renderTemplate Template a
    t b
    x = State Int (Doc a) -> Int -> Doc a
    forall s a. State s a -> s -> a
    S.evalState (Template a -> Context a -> State Int (Doc a)
    forall a.
    TemplateTarget a =>
    Template a -> Context a -> RenderState (Doc a)
    renderTemp Template a
    t (b -> Context a
    forall a b. ToContext a b => b -> Context a
    toContext b
    x)) Int
    0

    updateColumn :: TemplateTarget a => Doc a -> RenderState (Doc a)
    updateColumn :: forall a. TemplateTarget a => Doc a -> RenderState (Doc a)
    updateColumn Doc a
    x = do
      (Int -> Int) -> StateT Int Identity ()
    forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
    S.modify ((Int -> Int) -> StateT Int Identity ())
    -> (Int -> Int) -> StateT Int Identity ()
    forall a b. (a -> b) -> a -> b
    $ Doc a -> Int -> Int
    forall a. HasChars a => Doc a -> Int -> Int
    DL.updateColumn Doc a
    x
      Doc a -> StateT Int Identity (Doc a)
    forall a. a -> StateT Int Identity a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Doc a
    x

    renderTemp :: forall a . TemplateTarget a
               => Template a -> Context a -> RenderState (Doc a)
    renderTemp :: forall a.
    TemplateTarget a =>
    Template a -> Context a -> RenderState (Doc a)
    renderTemp (Literal Doc a
    t) Context a
    _ = Doc a -> RenderState (Doc a)
    forall a. TemplateTarget a => Doc a -> RenderState (Doc a)
    updateColumn Doc a
    t
    renderTemp (Interpolate Variable
    v) Context a
    ctx =
      case Variable -> Context a -> Resolved a
    forall a. TemplateTarget a => Variable -> Context a -> Resolved a
    resolveVariable Variable
    v Context a
    ctx of
        Resolved Bool
    _ [Doc a]
    xs -> Doc a -> RenderState (Doc a)
    forall a. TemplateTarget a => Doc a -> RenderState (Doc a)
    updateColumn ([Doc a] -> Doc a
    forall a. Monoid a => [a] -> a
    mconcat [Doc a]
    xs)
    renderTemp (Conditional Variable
    v Template a
    ift Template a
    elset) Context a
    ctx =
      case Variable -> Context a -> Resolved a
    forall a. TemplateTarget a => Variable -> Context a -> Resolved a
    resolveVariable Variable
    v Context a
    ctx of
        Resolved Bool
    False [Doc a]
    _ -> Template a -> Context a -> RenderState (Doc a)
    forall a.
    TemplateTarget a =>
    Template a -> Context a -> RenderState (Doc a)
    renderTemp Template a
    elset Context a
    ctx
        Resolved Bool
    True [Doc a]
    _  -> Template a -> Context a -> RenderState (Doc a)
    forall a.
    TemplateTarget a =>
    Template a -> Context a -> RenderState (Doc a)
    renderTemp Template a
    ift Context a
    ctx
    renderTemp (Iterate Variable
    v Template a
    t Template a
    sep) Context a
    ctx = do
      xs <- Variable
    -> Context a
    -> (Context a -> RenderState (Doc a))
    -> StateT Int Identity [Doc a]
    forall (m :: * -> *) a.
    (Monad m, TemplateTarget a) =>
    Variable -> Context a -> (Context a -> m (Doc a)) -> m [Doc a]
    withVariable Variable
    v Context a
    ctx (Template a -> Context a -> RenderState (Doc a)
    forall a.
    TemplateTarget a =>
    Template a -> Context a -> RenderState (Doc a)
    renderTemp Template a
    t)
      sep' <- renderTemp sep ctx
      return . mconcat . intersperse sep' $ xs
    renderTemp (Nested Template a
    t) Context a
    ctx = do
      n <- StateT Int Identity Int
    forall s (m :: * -> *). MonadState s m => m s
    S.get
      DL.nest n <$> renderTemp t ctx
    renderTemp (Partial [Pipe]
    fs Template a
    t) Context a
    ctx = do
        val' <- Template a -> Context a -> RenderState (Doc a)
    forall a.
    TemplateTarget a =>
    Template a -> Context a -> RenderState (Doc a)
    renderTemp Template a
    t Context a
    ctx
        return $ case applyPipes fs (SimpleVal val') of
          SimpleVal Doc a
    x -> Doc a
    x
          Val a
    _           -> Doc a
    forall a. Monoid a => a
    mempty
    renderTemp (Concat Template a
    t1 Template a
    t2) Context a
    ctx =
      Doc a -> Doc a -> Doc a
    forall a. Monoid a => a -> a -> a
    mappend (Doc a -> Doc a -> Doc a)
    -> RenderState (Doc a) -> StateT Int Identity (Doc a -> Doc a)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Template a -> Context a -> RenderState (Doc a)
    forall a.
    TemplateTarget a =>
    Template a -> Context a -> RenderState (Doc a)
    renderTemp Template a
    t1 Context a
    ctx StateT Int Identity (Doc a -> Doc a)
    -> RenderState (Doc a) -> RenderState (Doc a)
    forall a b.
    StateT Int Identity (a -> b)
    -> StateT Int Identity a -> StateT Int Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Template a -> Context a -> RenderState (Doc a)
    forall a.
    TemplateTarget a =>
    Template a -> Context a -> RenderState (Doc a)
    renderTemp Template a
    t2 Context a
    ctx
    renderTemp Template a
    Empty Context a
    _ = Doc a -> RenderState (Doc a)
    forall a. a -> StateT Int Identity a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Doc a
    forall a. Monoid a => a
    mempty

    -- | A 'TemplateMonad' defines a function to retrieve a partial
    -- (from the file system, from a database, or using a default
    -- value).
    class Monad m => TemplateMonad m where
      getPartial  :: FilePath -> m Text

    instance TemplateMonad Identity where
      getPartial :: String -> Identity Text
    getPartial String
    _  = Text -> Identity Text
    forall a. a -> Identity a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Text
    forall a. Monoid a => a
    mempty

    instance TemplateMonad IO where
      getPartial :: String -> IO Text
    getPartial = String -> IO Text
    TIO.readFile