-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Templating language with similar syntax and features to Liquid or Jinja2.
--
@package ede
@version 0.2.7
-- | 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 where quote _ _ = TVal . toJSON
quote :: Quote a => Id -> Int -> a -> Term
class Unquote a where unquote k n = \case { f@(TLam {}) -> typeErr k n (pretty f) "Value" TVal v -> case fromJSON v of { Success x -> pure x Error e -> argumentErr k n e } }
unquote :: Unquote 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 -> Doc -> Doc -> Result a
argumentErr :: Pretty a => Id -> Int -> a -> Result b
-- | A (mostly logicless) 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 Lazy Text 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 Text 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)
-- | 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
data Delta :: *
Columns :: SrictNotUnpackedInt64 -> SrictNotUnpackedInt64 -> Delta
Tab :: SrictNotUnpackedInt64 -> SrictNotUnpackedInt64 -> SrictNotUnpackedInt64 -> Delta
Lines :: SrictNotUnpackedInt64 -> SrictNotUnpackedInt64 -> SrictNotUnpackedInt64 -> SrictNotUnpackedInt64 -> Delta
Directed :: SrictNotUnpackedByteString -> SrictNotUnpackedInt64 -> SrictNotUnpackedInt64 -> SrictNotUnpackedInt64 -> SrictNotUnpackedInt64 -> Delta
-- | The result of running parsing or rendering steps.
data Result a
Success :: a -> Result a
Failure :: Doc -> 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 :: (Doc -> 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 => Doc -> 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
-- | Construct a Pair from a key and a value.
(.=) :: ToJSON a => Text -> a -> Pair
-- | ED-E Version.
version :: Version
type Delim = (String, String)
data Syntax
delimPragma :: HasSyntax c_afnZ => Lens' c_afnZ Delim
delimInline :: HasSyntax c_afnZ => Lens' c_afnZ Delim
delimComment :: HasSyntax c_afnZ => Lens' c_afnZ Delim
delimBlock :: HasSyntax c_afnZ => Lens' c_afnZ Delim
-- | The default ED-E syntax.
--
-- Delimiters:
--
--
-- - Pragma: {! ... !}
-- - Inline: {{ ... }}
-- - Comments: {}
-- - Blocks: {% ... %}
--
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:
--
--
-- - Inline: <@ ... @>
-- - Comments: @* ... *@
-- - Blocks: @( ... )@
--
alternateSyntax :: Syntax