-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Templating language with similar syntax and features to Liquid or Jinja2. -- -- ED-E is a templating language written in Haskell with a specific set -- of features: -- -- @package ede @version 0.3.2.0 -- | Warning: this is an internal module, and does not have a stable -- API or name. Functions in this module may not check or enforce -- preconditions expected by public modules. Use at your own risk! module Text.EDE.Internal.Types type AnsiDoc = Doc AnsiStyle class AnsiPretty a apretty :: AnsiPretty a => a -> AnsiDoc -- | Convenience wrapper for Pretty instances. newtype PP a PP :: a -> PP a [unPP] :: PP a -> a pp :: AnsiPretty (PP a) => a -> AnsiDoc () :: Doc ann -> Doc ann -> Doc ann bold :: AnsiDoc -> AnsiDoc red :: AnsiDoc -> AnsiDoc -- | The result of running parsing or rendering steps. data Result a Success :: a -> Result a Failure :: AnsiDoc -> Result a _Failure :: forall a_abo1. Prism' (Result a_abo1) AnsiDoc _Success :: forall a_abo1 a_ad3E. Prism (Result a_ad3E) (Result a_abo1) a_ad3E a_abo1 -- | Convert a Result to an Either with the Left case -- holding a formatted error message, and Right being the -- successful result over which Result is paramterised. eitherResult :: Result a -> Either String a -- | Perform a case analysis on a Result. result :: (AnsiDoc -> b) -> (a -> b) -> Result a -> b -- | Convenience for returning a successful Result. success :: Monad m => a -> m (Result a) -- | Convenience for returning an error Result. failure :: Monad m => AnsiDoc -> m (Result a) type Delim = (String, String) data Syntax Syntax :: !Delim -> !Delim -> !Delim -> !Delim -> Syntax [_delimPragma] :: Syntax -> !Delim [_delimInline] :: Syntax -> !Delim [_delimComment] :: Syntax -> !Delim [_delimBlock] :: Syntax -> !Delim class HasSyntax c_adjL syntax :: HasSyntax c_adjL => Lens' c_adjL Syntax delimBlock :: HasSyntax c_adjL => Lens' c_adjL Delim delimComment :: HasSyntax c_adjL => Lens' c_adjL Delim delimInline :: HasSyntax c_adjL => Lens' c_adjL Delim delimPragma :: HasSyntax c_adjL => Lens' c_adjL Delim -- | A function to resolve the target of an include expression. type Resolver m = Syntax -> Id -> Delta -> m (Result Template) -- | A parsed and compiled template. data Template Template :: !Text -> !Exp Delta -> HashMap Id (Exp Delta) -> Template [_tmplName] :: Template -> !Text [_tmplExp] :: Template -> !Exp Delta [_tmplIncl] :: Template -> HashMap Id (Exp Delta) type Id = Text newtype Var Var :: NonEmpty Id -> Var data Collection [Col] :: Foldable f => Int -> f (Maybe Text, Value) -> Collection data Pat PWild :: Pat PVar :: !Var -> Pat PLit :: !Value -> Pat type Alt a = (Pat, a) data ExpF a ELit :: !Value -> ExpF a EVar :: !Var -> ExpF a EFun :: !Id -> ExpF a EApp :: !a -> !a -> ExpF a ELet :: !Id -> !a -> !a -> ExpF a ECase :: !a -> [Alt a] -> ExpF a ELoop :: !Id -> !a -> !a -> ExpF a EIncl :: !Text -> ExpF a type Exp = Cofree ExpF -- | Unwrap a Value to an Object safely. -- -- See Aeson's documentation for more details. fromValue :: Value -> Maybe Object -- | Create an Object from a list of name/value Pairs. -- -- See Aeson's documentation for more details. fromPairs :: [Pair] -> Object instance GHC.Classes.Eq Text.EDE.Internal.Types.Var instance GHC.Show.Show Text.EDE.Internal.Types.Pat instance GHC.Classes.Eq Text.EDE.Internal.Types.Pat instance GHC.Base.Functor Text.EDE.Internal.Types.ExpF instance GHC.Show.Show a => GHC.Show.Show (Text.EDE.Internal.Types.ExpF a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Text.EDE.Internal.Types.ExpF a) instance GHC.Classes.Eq Text.EDE.Internal.Types.Template instance Text.Trifecta.Delta.HasDelta (Text.EDE.Internal.Types.Exp Text.Trifecta.Delta.Delta) instance Data.Functor.Classes.Eq1 Text.EDE.Internal.Types.ExpF instance Text.EDE.Internal.Types.AnsiPretty Text.EDE.Internal.Types.Var instance GHC.Show.Show Text.EDE.Internal.Types.Var instance Text.EDE.Internal.Types.HasSyntax Text.EDE.Internal.Types.Syntax instance GHC.Base.Monad Text.EDE.Internal.Types.Result instance GHC.Base.Applicative Text.EDE.Internal.Types.Result instance GHC.Base.Alternative Text.EDE.Internal.Types.Result instance GHC.Show.Show a => Text.EDE.Internal.Types.AnsiPretty (Text.EDE.Internal.Types.Result a) instance Data.Traversable.Traversable Text.EDE.Internal.Types.Result instance Data.Foldable.Foldable Text.EDE.Internal.Types.Result instance GHC.Base.Functor Text.EDE.Internal.Types.Result instance GHC.Show.Show a => GHC.Show.Show (Text.EDE.Internal.Types.Result a) instance Text.EDE.Internal.Types.AnsiPretty (Text.EDE.Internal.Types.PP Data.Text.Internal.Text) instance Text.EDE.Internal.Types.AnsiPretty (Text.EDE.Internal.Types.PP Data.Aeson.Types.Internal.Value) -- | Warning: this is an internal module, and does not have a stable -- API or name. Functions in this module may not check or enforce -- preconditions expected by public modules. Use at your own risk! module Text.EDE.Internal.Syntax -- | The default ED-E syntax. -- -- Delimiters: -- -- defaultSyntax :: Syntax -- | An alternate syntax (based on Play/Scala templates) designed to be -- used when the default is potentially ambiguous due to another -- encountered smarty based syntax. -- -- Delimiters: -- -- alternateSyntax :: Syntax commentStyle :: String -> String -> CommentStyle operatorStyle :: TokenParsing m => IdentifierStyle m variableStyle :: TokenParsing m => IdentifierStyle m keywordStyle :: TokenParsing m => IdentifierStyle m keywordSet :: HashSet String pragmaStyle :: TokenParsing m => IdentifierStyle m pragmaSet :: HashSet String -- | Warning: this is an internal module, and does not have a stable -- API or name. Functions in this module may not check or enforce -- preconditions expected by public modules. Use at your own risk! module Text.EDE.Internal.Quoting -- | A HOAS representation of (possibly partially applied) values in the -- environment. data Term TVal :: !Value -> Term TLam :: (Term -> Result Term) -> Term -- | Fully apply two Terms. qapply :: Delta -> Term -> Term -> Result Term -- | Quote a primitive Value from the top-level. qprim :: (ToJSON a, Quote a) => a -> Term class Unquote a unquote :: Unquote a => Id -> Int -> Term -> Result a unquote :: (Unquote a, FromJSON a) => Id -> Int -> Term -> Result a class Quote a quote :: Quote a => Id -> Int -> a -> Term quote :: (Quote a, ToJSON a) => Id -> Int -> a -> Term typeErr :: Id -> Int -> AnsiDoc -> AnsiDoc -> Result a argumentErr :: Pretty a => Id -> Int -> a -> Result b instance (Text.EDE.Internal.Quoting.Unquote a, Text.EDE.Internal.Quoting.Quote b) => Text.EDE.Internal.Quoting.Quote (a -> b) instance Text.EDE.Internal.Quoting.Quote Text.EDE.Internal.Quoting.Term instance Text.EDE.Internal.Quoting.Quote Data.Aeson.Types.Internal.Value instance Text.EDE.Internal.Quoting.Quote [Data.Aeson.Types.Internal.Value] instance Text.EDE.Internal.Quoting.Quote Data.Text.Internal.Text instance Text.EDE.Internal.Quoting.Quote [Data.Text.Internal.Text] instance Text.EDE.Internal.Quoting.Quote Data.Text.Internal.Lazy.Text instance Text.EDE.Internal.Quoting.Quote GHC.Types.Bool instance Text.EDE.Internal.Quoting.Quote GHC.Types.Int instance Text.EDE.Internal.Quoting.Quote GHC.Integer.Type.Integer instance Text.EDE.Internal.Quoting.Quote GHC.Types.Double instance Text.EDE.Internal.Quoting.Quote Data.Scientific.Scientific instance Text.EDE.Internal.Quoting.Quote Data.Aeson.Types.Internal.Object instance Text.EDE.Internal.Quoting.Quote Data.Aeson.Types.Internal.Array instance Text.EDE.Internal.Quoting.Quote Data.Text.Internal.Builder.Builder instance Text.EDE.Internal.Quoting.Unquote Data.Aeson.Types.Internal.Value instance Text.EDE.Internal.Quoting.Unquote Data.Text.Internal.Text instance Text.EDE.Internal.Quoting.Unquote [Data.Text.Internal.Text] instance Text.EDE.Internal.Quoting.Unquote Data.Text.Internal.Lazy.Text instance Text.EDE.Internal.Quoting.Unquote GHC.Types.Bool instance Text.EDE.Internal.Quoting.Unquote GHC.Types.Double instance Text.EDE.Internal.Quoting.Unquote Data.Scientific.Scientific instance Text.EDE.Internal.Quoting.Unquote Data.Aeson.Types.Internal.Object instance Text.EDE.Internal.Quoting.Unquote Data.Aeson.Types.Internal.Array instance Text.EDE.Internal.Quoting.Unquote GHC.Types.Int instance Text.EDE.Internal.Quoting.Unquote GHC.Integer.Type.Integer instance Text.EDE.Internal.Quoting.Unquote Text.EDE.Internal.Types.Collection instance Text.EDE.Internal.Types.AnsiPretty Text.EDE.Internal.Quoting.Term -- | Warning: this is an internal module, and does not have a stable -- API or name. Functions in this module may not check or enforce -- preconditions expected by public modules. Use at your own risk! module Text.EDE.Internal.Filters stdlib :: HashMap Text Term (@:) :: Quote a => Id -> a -> (Id, Term) -- | Quote a binary function which takes the most general binding value. qpoly2 :: Quote a => Id -> (Value -> Value -> a) -> (Id, Term) -- | Quote an unary numeric function. qnum1 :: Id -> (Scientific -> Scientific) -> (Id, Term) -- | Quote a binary numeric function. qnum2 :: Quote a => Id -> (Scientific -> Scientific -> a) -> (Id, Term) -- | Quote a comprehensive set of unary functions to create a binding that -- supports list collection types. qlist1 :: (Quote a, Quote b) => Id -> (Text -> a) -> (Array -> b) -> (Id, Term) -- | Quote a comprehensive set of unary functions to create a binding that -- supports all collection types. qcol1 :: (Quote a, Quote b, Quote c) => Id -> (Text -> a) -> (Object -> b) -> (Array -> c) -> (Id, Term) headT :: Text -> Value lastT :: Text -> Value tailT :: Text -> Value initT :: Text -> Value headV :: Array -> Value lastV :: Array -> Value tailV :: Array -> Value initV :: Array -> Value text :: (Text -> Text) -> Text -> Value vec :: (Array -> Value) -> Array -> Value safe :: b -> (a -> Bool) -> (a -> b) -> a -> b -- | The means to construct your own filters. module Text.EDE.Filters -- | A HOAS representation of (possibly partially applied) values in the -- environment. data Term TVal :: !Value -> Term TLam :: (Term -> Result Term) -> Term class Quote a quote :: Quote a => Id -> Int -> a -> Term quote :: (Quote a, ToJSON a) => Id -> Int -> a -> Term class Unquote a unquote :: Unquote a => Id -> Int -> Term -> Result a unquote :: (Unquote a, FromJSON a) => Id -> Int -> Term -> Result a (@:) :: Quote a => Id -> a -> (Id, Term) -- | Fully apply two Terms. qapply :: Delta -> Term -> Term -> Result Term -- | Quote a binary function which takes the most general binding value. qpoly2 :: Quote a => Id -> (Value -> Value -> a) -> (Id, Term) -- | Quote an unary numeric function. qnum1 :: Id -> (Scientific -> Scientific) -> (Id, Term) -- | Quote a binary numeric function. qnum2 :: Quote a => Id -> (Scientific -> Scientific -> a) -> (Id, Term) -- | Quote a comprehensive set of unary functions to create a binding that -- supports all collection types. qcol1 :: (Quote a, Quote b, Quote c) => Id -> (Text -> a) -> (Object -> b) -> (Array -> c) -> (Id, Term) typeErr :: Id -> Int -> AnsiDoc -> AnsiDoc -> Result a argumentErr :: Pretty a => Id -> Int -> a -> Result b -- | Warning: this is an internal module, and does not have a stable -- API or name. Functions in this module may not check or enforce -- preconditions expected by public modules. Use at your own risk! module Text.EDE.Internal.Eval data Env Env :: HashMap Id (Exp Delta) -> HashMap Id Term -> HashMap Id Value -> Env [_templates] :: Env -> HashMap Id (Exp Delta) [_quoted] :: Env -> HashMap Id Term [_values] :: Env -> HashMap Id Value type Context = ReaderT Env Result render :: HashMap Id (Exp Delta) -> HashMap Id Term -> Exp Delta -> HashMap Id Value -> Result Builder eval :: Exp Delta -> Context Term bind :: (Object -> Object) -> Context a -> Context a variable :: Delta -> Var -> Context Value -- | A variable can be tested for truthiness, but a non-whnf expr cannot. predicate :: Exp Delta -> Context Term binding :: Delta -> Term -> Term -> Context Term build :: Delta -> Value -> Context Builder throwError :: Delta -> AnsiDoc -> Context a -- | Warning: this is an internal module, and does not have a stable -- API or name. Functions in this module may not check or enforce -- preconditions expected by public modules. Use at your own risk! -- -- AST smart constructors. module Text.EDE.Internal.AST newtype Fix f Fix :: f (Fix f) -> Fix f cofreeFix :: Functor f => a -> Fix f -> Cofree f a var :: Id -> Var eapp :: a -> [Exp a] -> Exp a efun :: Id -> Exp a -> Exp a efilter :: Exp a -> (Id, [Exp a]) -> Exp a elet :: Maybe (Id, Exp a) -> Exp a -> Exp a ecase :: Exp a -> [Alt (Exp a)] -> Maybe (Exp a) -> Exp a eif :: (Exp a, Exp a) -> [(Exp a, Exp a)] -> Maybe (Exp a) -> Exp a eempty :: Exp a -> Exp a -> Maybe (Exp a) -> Exp a true :: Exp a -> Alt (Exp a) false :: Exp a -> Alt (Exp a) wild :: Exp a -> Alt (Exp a) blank :: Fix ExpF -- | Warning: this is an internal module, and does not have a stable -- API or name. Functions in this module may not check or enforce -- preconditions expected by public modules. Use at your own risk! module Text.EDE.Internal.Parser data Env Env :: !Syntax -> HashMap Text (NonEmpty Delta) -> Env [_settings] :: Env -> !Syntax [_includes] :: Env -> HashMap Text (NonEmpty Delta) settings :: Lens' Env Syntax includes :: Lens' Env (HashMap Text (NonEmpty Delta)) type Parser m = (Monad m, MonadFail m, MonadState Env m, TokenParsing m, DeltaParsing m, LookAheadParsing m, Errable m) newtype EDE a EDE :: Parser a -> EDE a [runEDE] :: EDE a -> Parser a runParser :: Syntax -> Text -> ByteString -> Result (Exp Delta, HashMap Text (NonEmpty Delta)) pragma :: Parser m => m () document :: Parser m => m (Exp Delta) inline :: Parser m => m (Exp Delta) fragment :: Parser m => m (Exp Delta) statement :: Parser m => m (Exp Delta) block :: Parser m => String -> m a -> m a multiLine :: Parser m => m b -> m a -> m a singleLine :: Parser m => m b -> m a -> m a blankLine :: Parser m => m (Exp Delta) ifelif :: Parser m => m (Exp Delta) cases :: Parser m => m (Exp Delta) loop :: Parser m => m (Exp Delta) include :: Parser m => m (Exp Delta) binding :: Parser m => m (Exp Delta) raw :: Parser m => m (Exp Delta) comment :: Parser m => m (Exp Delta) else' :: Parser m => m (Maybe (Exp Delta)) exit :: Parser m => String -> m () pattern :: Parser m => m Pat term :: Parser m => m (Exp Delta) term0 :: Parser m => m (Exp Delta) filter' :: Parser m => m (Id, [Exp Delta]) collection :: Parser m => m (Exp Delta) literal :: Parser m => m Value number :: Parser m => m Scientific bool :: Parser m => m Bool object :: Parser m => m Object array :: Parser m => m Array operator :: Parser m => Text -> m Delta keyword :: Parser m => String -> m Delta variable :: (Monad m, TokenParsing m) => m Var identifier :: (Monad m, TokenParsing m) => m Id spaces :: (Monad m, TokenParsing m) => m () manyTill1 :: Alternative m => m a -> m b -> m [a] manyEndBy1 :: Alternative m => m a -> m a -> m [a] chainl1' :: Alternative m => m a -> m b -> m (a -> b -> a) -> m a ann :: (DeltaParsing m, Functor f) => m (f (Fix f)) -> m (Cofree f Delta) pack :: Functor f => f String -> f Value triml :: Parser m => m a -> m a trimr :: Parser m => m a -> m a pragmak :: Parser m => String -> m () pragmal :: Parser m => m String pragmar :: Parser m => m String commentl :: MonadState Env m => m String commentr :: MonadState Env m => m String inlinel :: Parser m => m String inliner :: Parser m => m String blockl :: Parser m => m String blockr :: Parser m => m String left :: MonadState s m => Getter s Delim -> m String right :: MonadState s m => Getter s Delim -> m String instance Text.Trifecta.Result.Errable Text.EDE.Internal.Parser.EDE instance Text.Parser.LookAhead.LookAheadParsing Text.EDE.Internal.Parser.EDE instance Text.Trifecta.Combinators.DeltaParsing Text.EDE.Internal.Parser.EDE instance Text.Parser.Char.CharParsing Text.EDE.Internal.Parser.EDE instance Text.Parser.Combinators.Parsing Text.EDE.Internal.Parser.EDE instance GHC.Base.MonadPlus Text.EDE.Internal.Parser.EDE instance Control.Monad.Fail.MonadFail Text.EDE.Internal.Parser.EDE instance GHC.Base.Monad Text.EDE.Internal.Parser.EDE instance GHC.Base.Alternative Text.EDE.Internal.Parser.EDE instance GHC.Base.Applicative Text.EDE.Internal.Parser.EDE instance GHC.Base.Functor Text.EDE.Internal.Parser.EDE instance Text.Parser.Token.TokenParsing Text.EDE.Internal.Parser.EDE instance Text.Trifecta.Result.Errable (Control.Monad.Trans.State.Strict.StateT Text.EDE.Internal.Parser.Env Text.EDE.Internal.Parser.EDE) instance Text.EDE.Internal.Types.HasSyntax Text.EDE.Internal.Parser.Env -- | A (mostly) logic-less textual templating language with similar syntax -- to Liquid or Jinja2. -- -- (ED-E is a character from Fallout New Vegas, pronounced -- Eddie.) module Text.EDE -- | A parsed and compiled template. data Template -- | Parse a ByteString into a compiled Template. -- -- Because this function is pure and does not resolve includes, -- encountering an include expression during parsing will result -- in an Error. -- -- See parseFile or parseWith for mechanisms to deal with -- include dependencies. parse :: ByteString -> Result Template -- | Parse a ByteString into a compiled Template. -- -- This function handles all include expressions as -- FilePaths and performs recursive loading/parsing. parseIO :: FilePath -> ByteString -> IO (Result Template) -- | Load and parse a Template from a file. -- -- This function handles all include expressions as -- FilePaths and performs recursive loading/parsing, with pathing -- of includes relatively to the target (unless absolute paths -- are used). parseFile :: FilePath -> IO (Result Template) -- | See: parseFile. parseFileWith :: Syntax -> FilePath -> IO (Result Template) -- | Parse a Template from a Strict ByteString using a custom -- function for resolving include expressions. -- -- Two custom include resolvers are supplied: -- -- -- -- parseFile for example, is defined as: parseWith -- includeFile. parseWith :: Monad m => Syntax -> Resolver m -> Text -> ByteString -> m (Result Template) -- | A function to resolve the target of an include expression. type Resolver m = Syntax -> Id -> Delta -> m (Result Template) type Id = Text -- | HashMap resolver for include expressions. -- -- The identifier component of the include expression -- is treated as a lookup key into the supplied HashMap. If the -- identifier doesn't exist in the HashMap, an -- Error is returned. includeMap :: Monad m => HashMap Id Template -> Resolver m -- | FilePath resolver for include expressions. -- -- The identifier component of the include expression -- is treated as a relative FilePath and the template is loaded -- and parsed using parseFile. If the identifier doesn't -- exist as a valid FilePath, an Error is returned. includeFile :: FilePath -> Resolver IO -- | Render an Object using the supplied Template. render :: Template -> Object -> Result Text -- | Render an Object using the supplied Template. renderWith :: HashMap Id Term -> Template -> Object -> Result Text -- | See: parse eitherParse :: ByteString -> Either String Template -- | See: parseFile eitherParseFile :: FilePath -> IO (Either String Template) -- | See: parseWith eitherParseWith :: (Functor m, Monad m) => Syntax -> Resolver m -> Text -> ByteString -> m (Either String Template) -- | See: render eitherRender :: Template -> Object -> Either String Text -- | See: renderWith eitherRenderWith :: HashMap Id Term -> Template -> Object -> Either String Text -- | Since there are multiple ways to be at a certain location, -- Delta captures all these alternatives as a single type. data Delta -- |
--   ( number of characters
--   , number of bytes )
--   
Columns :: {-# UNPACK #-} !Int64 -> {-# UNPACK #-} !Int64 -> Delta -- |
--   ( number of characters before the tab
--   , number of characters after the tab
--   , number of bytes )
--   
Tab :: {-# UNPACK #-} !Int64 -> {-# UNPACK #-} !Int64 -> {-# UNPACK #-} !Int64 -> Delta -- |
--   ( number of newlines contained
--   , number of characters since the last newline
--   , number of bytes
--   , number of bytes since the last newline )
--   
Lines :: {-# UNPACK #-} !Int64 -> {-# UNPACK #-} !Int64 -> {-# UNPACK #-} !Int64 -> {-# UNPACK #-} !Int64 -> Delta -- |
--   ( current file name
--   , number of lines since the last line directive
--   , number of characters since the last newline
--   , number of bytes
--   , number of bytes since the last newline )
--   
Directed :: !ByteString -> {-# UNPACK #-} !Int64 -> {-# UNPACK #-} !Int64 -> {-# UNPACK #-} !Int64 -> {-# UNPACK #-} !Int64 -> Delta -- | The result of running parsing or rendering steps. data Result a Success :: a -> Result a Failure :: AnsiDoc -> Result a -- | Convert a Result to an Either with the Left case -- holding a formatted error message, and Right being the -- successful result over which Result is paramterised. eitherResult :: Result a -> Either String a -- | Perform a case analysis on a Result. result :: (AnsiDoc -> b) -> (a -> b) -> Result a -> b -- | Convenience for returning a successful Result. success :: Monad m => a -> m (Result a) -- | Convenience for returning an error Result. failure :: Monad m => AnsiDoc -> m (Result a) -- | Unwrap a Value to an Object safely. -- -- See Aeson's documentation for more details. fromValue :: Value -> Maybe Object -- | Create an Object from a list of name/value Pairs. -- -- See Aeson's documentation for more details. fromPairs :: [Pair] -> Object (.=) :: (KeyValue kv, ToJSON v) => Text -> v -> kv infixr 8 .= -- | ED-E Version. version :: Version type Delim = (String, String) data Syntax delimPragma :: HasSyntax c_adjL => Lens' c_adjL Delim delimInline :: HasSyntax c_adjL => Lens' c_adjL Delim delimComment :: HasSyntax c_adjL => Lens' c_adjL Delim delimBlock :: HasSyntax c_adjL => Lens' c_adjL Delim -- | The default ED-E syntax. -- -- Delimiters: -- -- defaultSyntax :: Syntax -- | An alternate syntax (based on Play/Scala templates) designed to be -- used when the default is potentially ambiguous due to another -- encountered smarty based syntax. -- -- Delimiters: -- -- alternateSyntax :: Syntax