mustache-2.4.2: A mustache template parser library.
Copyright(c) Justus Adam 2015
LicenseBSD3
Maintainerdev@justus.science
Stabilityexperimental
PortabilityPOSIX
Safe HaskellSafe-Inferred
LanguageHaskell2010

Text.Mustache.Types

Description

 
Synopsis

Types for the Parser / Template

type ASTree α = [Node α] Source #

type STree = ASTree Text Source #

Syntax tree for a mustache template

data Node α Source #

Basic values composing the STree

Instances

Instances details
Lift α => Lift (Node α :: Type) Source # 
Instance details

Defined in Text.Mustache.Internal.Types

Methods

lift :: Quote m => Node α -> m Exp #

liftTyped :: forall (m :: Type -> Type). Quote m => Node α -> Code m (Node α) #

Show α => Show (Node α) Source # 
Instance details

Defined in Text.Mustache.Internal.Types

Methods

showsPrec :: Int -> Node α -> ShowS #

show :: Node α -> String #

showList :: [Node α] -> ShowS #

Eq α => Eq (Node α) Source # 
Instance details

Defined in Text.Mustache.Internal.Types

Methods

(==) :: Node α -> Node α -> Bool #

(/=) :: Node α -> Node α -> Bool #

ToMustache (Context Value -> STree -> STree) Source # 
Instance details

Defined in Text.Mustache.Render

ToMustache (Context Value -> STree -> Text) Source # 
Instance details

Defined in Text.Mustache.Render

ToMustache (Context Value -> STree -> Text) Source # 
Instance details

Defined in Text.Mustache.Render

ToMustache (Context Value -> STree -> String) Source # 
Instance details

Defined in Text.Mustache.Render

ToMustache (STree -> SubM STree) Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache (STree -> SubM Text) Source # 
Instance details

Defined in Text.Mustache.Render

data DataIdentifier Source #

Kinds of identifiers for Variables and sections

Constructors

NamedData [Key] 
Implicit 

data Template Source #

A compiled Template with metadata.

Constructors

Template 

Instances

Instances details
Show Template Source # 
Instance details

Defined in Text.Mustache.Internal.Types

Lift Template Source # 
Instance details

Defined in Text.Mustache.Internal.Types

Methods

lift :: Quote m => Template -> m Exp #

liftTyped :: forall (m :: Type -> Type). Quote m => Template -> Code m Template #

MonadReader (Context Value, TemplateCache) SubM Source # 
Instance details

Defined in Text.Mustache.Internal.Types

type TemplateCache = HashMap String Template Source #

A collection of templates with quick access via their hashed names

Types for the Substitution / Data

data Value Source #

Internal value representation

Instances

Instances details
Show Value Source # 
Instance details

Defined in Text.Mustache.Internal.Types

Methods

showsPrec :: Int -> Value -> ShowS #

show :: Value -> String #

showList :: [Value] -> ShowS #

ToMustache Value Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache (Context Value -> STree -> STree) Source # 
Instance details

Defined in Text.Mustache.Render

ToMustache (Context Value -> STree -> Text) Source # 
Instance details

Defined in Text.Mustache.Render

ToMustache (Context Value -> STree -> Text) Source # 
Instance details

Defined in Text.Mustache.Render

ToMustache (Context Value -> STree -> String) Source # 
Instance details

Defined in Text.Mustache.Render

MonadReader (Context Value, TemplateCache) SubM Source # 
Instance details

Defined in Text.Mustache.Internal.Types

type Key = Text Source #

Type of key used for retrieving data from Values

Converting

object :: [Pair] -> Value Source #

Convenience function for creating Object values.

This function is supposed to be used in conjuction with the ~> and ~= operators.

Examples

Expand
  data Address = Address { ... }

  instance Address ToJSON where
    ...

  data Person = Person { name :: String, address :: Address }

  instance ToMustache Person where
    toMustache (Person { name, address }) = object
      [ "name" ~> name
      , "address" ~= address
      ]

Here we can see that we can use the ~> operator for values that have themselves a ToMustache instance, or alternatively if they lack such an instance but provide an instance for the ToJSON typeclass we can use the ~= operator.

(~>) :: ToMustache ω => Text -> ω -> Pair infixr 8 Source #

Map keys to values that provide a ToMustache instance

Recommended in conjunction with the OverloadedStrings extension.

(↝) :: ToMustache ω => Text -> ω -> Pair infixr 8 Source #

Unicode version of ~>

(~=) :: ToJSON ι => Text -> ι -> Pair infixr 8 Source #

Map keys to values that provide a ToJSON instance

Recommended in conjunction with the OverloadedStrings extension.

(⥱) :: ToJSON ι => Text -> ι -> Pair infixr 8 Source #

Unicode version of ~=

class ToMustache ω Source #

Conversion class

Minimal complete definition

toMustache

Instances

Instances details
ToMustache Value Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache Int16 Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache Int32 Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache Int64 Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache Int8 Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache Word16 Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache Word32 Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache Word64 Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache Word8 Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache Value Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache Scientific Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache Text Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache Text Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache Integer Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache Natural Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache () Source # 
Instance details

Defined in Text.Mustache.Internal.Types

Methods

toMustache :: () -> Value Source #

listToMustache :: [()] -> Value

ToMustache Bool Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache Char Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache Double Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache Float Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache Int Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache Word Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache ω => ToMustache (Seq ω) Source # 
Instance details

Defined in Text.Mustache.Internal.Types

Methods

toMustache :: Seq ω -> Value Source #

listToMustache :: [Seq ω] -> Value

ToMustache ω => ToMustache (Set ω) Source # 
Instance details

Defined in Text.Mustache.Internal.Types

Methods

toMustache :: Set ω -> Value Source #

listToMustache :: [Set ω] -> Value

ToMustache ω => ToMustache (HashSet ω) Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache ω => ToMustache (Vector ω) Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache ω => ToMustache (Maybe ω) Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache α => ToMustache [α] Source # 
Instance details

Defined in Text.Mustache.Internal.Types

Methods

toMustache :: [α] -> Value Source #

listToMustache :: [[α]] -> Value

ToMustache ω => ToMustache (Map Text ω) Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache ω => ToMustache (Map Text ω) Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache ω => ToMustache (Map String ω) Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache ω => ToMustache (HashMap Text ω) Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache ω => ToMustache (HashMap Text ω) Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache ω => ToMustache (HashMap String ω) Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache (Context Value -> STree -> STree) Source # 
Instance details

Defined in Text.Mustache.Render

ToMustache (Context Value -> STree -> Text) Source # 
Instance details

Defined in Text.Mustache.Render

ToMustache (Context Value -> STree -> Text) Source # 
Instance details

Defined in Text.Mustache.Render

ToMustache (Context Value -> STree -> String) Source # 
Instance details

Defined in Text.Mustache.Render

ToMustache (STree -> SubM STree) Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache (STree -> SubM Text) Source # 
Instance details

Defined in Text.Mustache.Render

(ToMustache α, ToMustache β) => ToMustache (α, β) Source # 
Instance details

Defined in Text.Mustache.Internal.Types

Methods

toMustache :: (α, β) -> Value Source #

listToMustache :: [(α, β)] -> Value

(ToMustache α, ToMustache β, ToMustache γ) => ToMustache (α, β, γ) Source # 
Instance details

Defined in Text.Mustache.Internal.Types

Methods

toMustache :: (α, β, γ) -> Value Source #

listToMustache :: [(α, β, γ)] -> Value

(ToMustache α, ToMustache β, ToMustache γ, ToMustache δ) => ToMustache (α, β, γ, δ) Source # 
Instance details

Defined in Text.Mustache.Internal.Types

Methods

toMustache :: (α, β, γ, δ) -> Value Source #

listToMustache :: [(α, β, γ, δ)] -> Value

(ToMustache α, ToMustache β, ToMustache γ, ToMustache δ, ToMustache ε) => ToMustache (α, β, γ, δ, ε) Source # 
Instance details

Defined in Text.Mustache.Internal.Types

Methods

toMustache :: (α, β, γ, δ, ε) -> Value Source #

listToMustache :: [(α, β, γ, δ, ε)] -> Value

(ToMustache α, ToMustache β, ToMustache γ, ToMustache δ, ToMustache ε, ToMustache ζ) => ToMustache (α, β, γ, δ, ε, ζ) Source # 
Instance details

Defined in Text.Mustache.Internal.Types

Methods

toMustache :: (α, β, γ, δ, ε, ζ) -> Value Source #

listToMustache :: [(α, β, γ, δ, ε, ζ)] -> Value

(ToMustache α, ToMustache β, ToMustache γ, ToMustache δ, ToMustache ε, ToMustache ζ, ToMustache η) => ToMustache (α, β, γ, δ, ε, ζ, η) Source # 
Instance details

Defined in Text.Mustache.Internal.Types

Methods

toMustache :: (α, β, γ, δ, ε, ζ, η) -> Value Source #

listToMustache :: [(α, β, γ, δ, ε, ζ, η)] -> Value

(ToMustache α, ToMustache β, ToMustache γ, ToMustache δ, ToMustache ε, ToMustache ζ, ToMustache η, ToMustache θ) => ToMustache (α, β, γ, δ, ε, ζ, η, θ) Source # 
Instance details

Defined in Text.Mustache.Internal.Types

Methods

toMustache :: (α, β, γ, δ, ε, ζ, η, θ) -> Value Source #

listToMustache :: [(α, β, γ, δ, ε, ζ, η, θ)] -> Value

mFromJSON :: ToJSON ι => ι -> Value Source #

Converts a value that can be represented as JSON to a Value.

Representation

type Array = Vector Value Source #

A list-like structure used in Value

type Object = HashMap Text Value Source #

A map-like structure used in Value

type Pair = (Text, Value) Source #

Source type for constructing Objects

data SubM a Source #

Instances

Instances details
Applicative SubM Source # 
Instance details

Defined in Text.Mustache.Internal.Types

Methods

pure :: a -> SubM a #

(<*>) :: SubM (a -> b) -> SubM a -> SubM b #

liftA2 :: (a -> b -> c) -> SubM a -> SubM b -> SubM c #

(*>) :: SubM a -> SubM b -> SubM b #

(<*) :: SubM a -> SubM b -> SubM a #

Functor SubM Source # 
Instance details

Defined in Text.Mustache.Internal.Types

Methods

fmap :: (a -> b) -> SubM a -> SubM b #

(<$) :: a -> SubM b -> SubM a #

Monad SubM Source # 
Instance details

Defined in Text.Mustache.Internal.Types

Methods

(>>=) :: SubM a -> (a -> SubM b) -> SubM b #

(>>) :: SubM a -> SubM b -> SubM b #

return :: a -> SubM a #

ToMustache (STree -> SubM STree) Source # 
Instance details

Defined in Text.Mustache.Internal.Types

ToMustache (STree -> SubM Text) Source # 
Instance details

Defined in Text.Mustache.Render

MonadReader (Context Value, TemplateCache) SubM Source # 
Instance details

Defined in Text.Mustache.Internal.Types

data Context α Source #

Representation of stateful context for the substitution process

Constructors

Context 

Fields

Instances

Instances details
Show α => Show (Context α) Source # 
Instance details

Defined in Text.Mustache.Internal.Types

Methods

showsPrec :: Int -> Context α -> ShowS #

show :: Context α -> String #

showList :: [Context α] -> ShowS #

Eq α => Eq (Context α) Source # 
Instance details

Defined in Text.Mustache.Internal.Types

Methods

(==) :: Context α -> Context α -> Bool #

(/=) :: Context α -> Context α -> Bool #

Ord α => Ord (Context α) Source # 
Instance details

Defined in Text.Mustache.Internal.Types

Methods

compare :: Context α -> Context α -> Ordering #

(<) :: Context α -> Context α -> Bool #

(<=) :: Context α -> Context α -> Bool #

(>) :: Context α -> Context α -> Bool #

(>=) :: Context α -> Context α -> Bool #

max :: Context α -> Context α -> Context α #

min :: Context α -> Context α -> Context α #

ToMustache (Context Value -> STree -> STree) Source # 
Instance details

Defined in Text.Mustache.Render

ToMustache (Context Value -> STree -> Text) Source # 
Instance details

Defined in Text.Mustache.Render

ToMustache (Context Value -> STree -> Text) Source # 
Instance details

Defined in Text.Mustache.Render

ToMustache (Context Value -> STree -> String) Source # 
Instance details

Defined in Text.Mustache.Render

MonadReader (Context Value, TemplateCache) SubM Source # 
Instance details

Defined in Text.Mustache.Internal.Types