-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Liquid template language library -- -- This package should be used by importing Text.Liquid. Sundry nested -- packages can be used freely for other functionality. See the readme on -- Github for more details on usage. @package liquid @version 0.1.0.2 module Text.Liquid.Types type JsonVarPath = NonEmpty VarIndex data VarIndex ObjectIndex :: Text -> VarIndex ArrayIndex :: Int -> VarIndex data Expr Noop :: Expr RawText :: Text -> Expr Num :: Scientific -> Expr Variable :: JsonVarPath -> Expr QuoteString :: Text -> Expr Equal :: Expr -> Expr -> Expr NotEqual :: Expr -> Expr -> Expr GtEqual :: Expr -> Expr -> Expr LtEqual :: Expr -> Expr -> Expr Gt :: Expr -> Expr -> Expr Lt :: Expr -> Expr -> Expr Or :: Expr -> Expr -> Expr And :: Expr -> Expr -> Expr Contains :: Expr -> Expr -> Expr Nil :: Expr Null :: Expr Trueth :: Expr Falseth :: Expr Truthy :: Expr -> Expr IfClause :: Expr -> Expr IfKeyClause :: Expr -> Expr ElsIfClause :: Expr -> Expr Else :: Expr FilterCell :: Text -> [Expr] -> Expr Filter :: Expr -> [Expr] -> Expr Output :: Expr -> Expr TrueStatements :: [Expr] -> Expr IfLogic :: Expr -> Expr -> Expr CaseLogic :: Expr -> [(Expr, Expr)] -> Expr _CaseLogic :: Prism' Expr (Expr, [(Expr, Expr)]) _IfLogic :: Prism' Expr (Expr, Expr) _TrueStatements :: Prism' Expr [Expr] _Output :: Prism' Expr Expr _Filter :: Prism' Expr (Expr, [Expr]) _FilterCell :: Prism' Expr (Text, [Expr]) _Else :: Prism' Expr () _ElsIfClause :: Prism' Expr Expr _IfKeyClause :: Prism' Expr Expr _IfClause :: Prism' Expr Expr _Truthy :: Prism' Expr Expr _Falseth :: Prism' Expr () _Trueth :: Prism' Expr () _Null :: Prism' Expr () _Nil :: Prism' Expr () _Contains :: Prism' Expr (Expr, Expr) _And :: Prism' Expr (Expr, Expr) _Or :: Prism' Expr (Expr, Expr) _Lt :: Prism' Expr (Expr, Expr) _Gt :: Prism' Expr (Expr, Expr) _LtEqual :: Prism' Expr (Expr, Expr) _GtEqual :: Prism' Expr (Expr, Expr) _NotEqual :: Prism' Expr (Expr, Expr) _Equal :: Prism' Expr (Expr, Expr) _QuoteString :: Prism' Expr Text _Variable :: Prism' Expr JsonVarPath _Num :: Prism' Expr Scientific _RawText :: Prism' Expr Text _Noop :: Prism' Expr () type Rendering a = AccValidation [LiquidError] a data LiquidError TemplateParsingError :: Text -> Text -> [Text] -> LiquidError JsonValueError :: Text -> LiquidError JsonValueNotFound :: JsonVarPath -> LiquidError NotAStringOrNumberJsonValue :: (Rendering Value) -> LiquidError ImpossibleComparison :: Text -> Text -> LiquidError ImpossibleTruthEvaluation :: Expr -> LiquidError RenderingFailure :: Text -> LiquidError LiquidError :: Text -> LiquidError instance GHC.Show.Show Text.Liquid.Types.LiquidError instance GHC.Classes.Eq Text.Liquid.Types.LiquidError instance GHC.Show.Show Text.Liquid.Types.Expr instance GHC.Classes.Eq Text.Liquid.Types.Expr instance GHC.Show.Show Text.Liquid.Types.VarIndex instance GHC.Classes.Ord Text.Liquid.Types.VarIndex instance GHC.Classes.Eq Text.Liquid.Types.VarIndex module Text.Liquid.VariableFinder -- | Allowed types data VType VString :: VType VNumber :: VType VStringOrNumber :: VType VBool :: VType VAny :: VType -- | Map findAllVariables across terms from parsed template and concatenate -- variable with inferred type findAllVariables :: [Expr] -> [(JsonVarPath, VType)] -- | Find all the variables in a node's children, with a type scope findVariables :: StateT VType [] JsonVarPath -> Expr -> StateT VType [] JsonVarPath -- | Find all context variables and add a sample filter. Designed to -- simulate required templates for aggregate contexts - see JsonTools makeAggregate :: Expr -> VarIndex -> [Expr] -> [Expr] aggregateElem :: Expr -> VarIndex -> Expr -> Expr updateFs :: Expr -> [Expr] -> [Expr] instance GHC.Show.Show Text.Liquid.VariableFinder.VType instance GHC.Classes.Eq Text.Liquid.VariableFinder.VType module Text.Liquid.Tokens and :: Parser Text assign :: Parser Text break :: Parser Text cBr :: Parser Char cPar :: Parser Char captureEnd :: Parser Text captureStart :: Parser Text caseEnd :: Parser Text caseStart :: Parser Text colon :: Parser Char comma :: Parser Char commentEnd :: Parser Text commentStart :: Parser Text contains :: Parser Text continue :: Parser Text cycle :: Parser Text dot :: Parser Char dotDot :: Parser Text els :: Parser Text elsIf :: Parser Text empty :: Parser Text end :: Parser Text endIf :: Parser Text eq :: Parser Text eqSign :: Parser Char false :: Parser Text forEnd :: Parser Text forStart :: Parser Text gt :: Parser Char gtEq :: Parser Text iN :: Parser Text ifKeyStart :: Parser Text ifStart :: Parser Text include :: Parser Text lt :: Parser Char ltEq :: Parser Text minus :: Parser Char neq :: Parser Text nil :: Parser Text null :: Parser Text oBr :: Parser Char oPar :: Parser Char or :: Parser Text outputEnd :: Parser Text outputStart :: Parser Text pipe :: Parser Char qMark :: Parser Char rawEnd :: Parser Text rawStart :: Parser Text tableEnd :: Parser Text tableStart :: Parser Text tagEnd :: Parser Text tagStart :: Parser Text true :: Parser Text underscore :: Parser Char unlessEnd :: Parser Text unlessStart :: Parser Text when :: Parser Text with :: Parser Text module Text.Liquid.Helpers -- | Strict monadic foldl foldM' :: Monad m => (a -> b -> m a) -> a -> [b] -> m a -- | Format a number formatNum :: Scientific -> Text -- | Compose a traversal into a JSON Value buildLens :: forall (f :: * -> *). Applicative f => JsonVarPath -> ((Value -> f Value) -> Value -> f Value) renderPath :: JsonVarPath -> Text renderExpr :: Expr -> Text module Text.Liquid.Parser -- | Match middle parser, around explicit start and end parsers between :: Parser b -> Parser b -> Parser a -> Parser a -- | Match parser between whitespace stripped :: Parser a -> Parser a -- | Match given parser for a tag tag :: Parser a -> Parser a -- | Match given parser for output block outputTag :: Parser a -> Parser a -- | Match given tag name (e.g. for, case) with following parser tagWith :: Parser a -> Parser b -> Parser b -- | Convert match into text mapT :: Parser [Char] -> Parser Text -- | Match variables (without indices, including underscore or hash) var :: Parser Text -- | Parse a positive integer within square brackets, e.g. "[123]", NOT -- "[123.1]" parseBoxedInt :: Parser Int -- | Parse a variable section with an optional indexing An array index MUST -- be preceded by an object index ...hence Maybe do comprehension varIndexSection :: Parser (NonEmpty VarIndex) -- | Parse a variable variable :: Parser Expr -- | e.g. raw tag, comment tag rawBodyTag :: Parser Text -> Parser Text -> Parser Text -- | Match interior of raw tag rawTag :: Parser Expr -- | Match interior of comment tag commentTag :: Parser Expr -- | Match any raw text upto a tag/output start or the end of the input textPart :: Parser Expr -- | Force the first character to be valid, otherwise fail miserably manyTill1 :: Alternative f => f a -> f b -> f [a] -- | Match an Ord comparison operator ordOperator :: Parser (Expr -> Expr -> Expr) -- | Match an or, and or contains predicate ordCombinator :: Parser (Expr -> Expr -> Expr) -- | Match a quoted string quoteString :: Parser Expr -- | Match a binary predicate, e.g. a.b >= b.name binaryPredicate :: Parser Expr -- | Parse and evaluate truthiness truthy :: Parser Expr -- | Match a binary predicate, e.g. a.b >= b.name or barry predicate :: Parser Expr -- | Match any predicate clause predicateClause :: Parser Expr -- | Match an if clause ifClause :: Parser Expr -- | Match an ifkey clause ifKeyClause :: Parser Expr -- | Match an elsif clause elsifClause :: Parser Expr -- | Match an else clause elseClause :: Parser Expr -- | Match the end of an if clause endIfClause :: Parser Expr -- | Match a variable condition for a case clause caseClause :: Parser Expr -- | Match a when clause, part of a case pattern match block whenClause :: Parser Expr -- | Match the end of a case pattern match block endCaseClause :: Parser Expr -- | Match a filter fn name filterName :: Parser Text -- | Match the list of arguments for the filter fn filterArgs :: Parser [Expr] -- | Match a filter cell, fn and args filterCell :: Parser Expr -- | Type check the function args and check arity typeCheckFilter :: Text -> [Expr] -> Parser Expr -- | Match multiple filter fns and args filterCells :: Parser [Expr] -- | Match a lhs and a block of filters with their args filterBlock :: Parser Expr -- | Output block, a variable, indexed variable, number or filter block output :: Parser Expr -- | If statement, optional elsif or else ifLogic :: Parser Expr -- | Case pattern match block caseLogic :: Parser Expr -- | Parse any block type block :: Parser Expr -- | Parse an entire template into chunks templateParser :: Parser [Expr] -- | Run the templateParser on input text, force partial results to -- terminate with Failure parseTemplate :: Text -> IResult Text [Expr] templateP :: Prism' Text [Expr] module Text.Liquid.Renderer -- | Interpret function - for use in testing the lib interpretWithJson :: Value -> Text -> Rendering Text -- | Interpret the raw data if it is ok interpret :: Value -> [Expr] -> Rendering Text -- | Rendering types -- -- Main template block rendering fn renderTemplate :: Value -> Expr -> Rendering Text -- | Evaluate predicate result and render evalLogic :: Value -> Rendering Bool -> [Expr] -> Rendering Text -- | Evaluate case logic evalCaseLogic :: Value -> Rendering Value -> [(Expr, Expr)] -> Rendering Text -- | Render a renderable Expr as Text renderText :: Value -> Expr -> Rendering Text -- | Format variable as either number or Text numberOrTextFormat :: Rendering Value -> Rendering Text -- | Eval key present & not null evalKeyTruthiness :: Value -> Expr -> Rendering Bool -- | Eval truth evalTruthiness :: Value -> Expr -> Rendering Bool -- | Check if the variable contains the thing on the rhs containsCheck :: Value -> Expr -> Expr -> Rendering Bool -- | Aggregate all the strings in the underlying array - if present getStringsFromArray :: Value -> [Text] -- | Aggregate all the numbers in the underlying array - if present getNumbersFromArray :: Value -> [Scientific] -- | Truth evaluation with variables ONLY numberic comparison allowed, text -- comparisons not supported varComparisons :: Value -> (Maybe Scientific -> Maybe Scientific -> Bool) -> Expr -> Expr -> Rendering Bool -- | Evaluate a binary comparison bothSidesEqual :: Value -> Expr -> Expr -> Rendering Bool -- | Fold over multiple layers of variable syntax, and deal with future -- event nesting extractValue :: Value -> JsonVarPath -> Rendering Value -- | Apply a filter to the input applyFilter :: Value -> Expr -> Rendering Text -- | Apply a chain of functions from l -> r applyCellsM :: Value -> [Expr] -> Maybe Text -- | Apply a filter applyFilterM :: Text -> Expr -> Maybe Text -- | Apply the array filter if the targeted value is an array, otherwise -- the reg filter arrayFilterM :: Value -> Expr -> Maybe Text -- | Apply an array filter to an array applyArrayFilterM :: [Value] -> Expr -> Maybe Text renderv :: Value -> Maybe Text -- | Render each array element (can only contain strings or numbers!) renderEachArrayElem :: [Value] -> Maybe [Text] module Text.Liquid data Expr Noop :: Expr RawText :: Text -> Expr Num :: Scientific -> Expr Variable :: JsonVarPath -> Expr QuoteString :: Text -> Expr Equal :: Expr -> Expr -> Expr NotEqual :: Expr -> Expr -> Expr GtEqual :: Expr -> Expr -> Expr LtEqual :: Expr -> Expr -> Expr Gt :: Expr -> Expr -> Expr Lt :: Expr -> Expr -> Expr Or :: Expr -> Expr -> Expr And :: Expr -> Expr -> Expr Contains :: Expr -> Expr -> Expr Nil :: Expr Null :: Expr Trueth :: Expr Falseth :: Expr Truthy :: Expr -> Expr IfClause :: Expr -> Expr IfKeyClause :: Expr -> Expr ElsIfClause :: Expr -> Expr Else :: Expr FilterCell :: Text -> [Expr] -> Expr Filter :: Expr -> [Expr] -> Expr Output :: Expr -> Expr TrueStatements :: [Expr] -> Expr IfLogic :: Expr -> Expr -> Expr CaseLogic :: Expr -> [(Expr, Expr)] -> Expr type JsonVarPath = NonEmpty VarIndex data LiquidError TemplateParsingError :: Text -> Text -> [Text] -> LiquidError JsonValueError :: Text -> LiquidError JsonValueNotFound :: JsonVarPath -> LiquidError NotAStringOrNumberJsonValue :: (Rendering Value) -> LiquidError ImpossibleComparison :: Text -> Text -> LiquidError ImpossibleTruthEvaluation :: Expr -> LiquidError RenderingFailure :: Text -> LiquidError LiquidError :: Text -> LiquidError type Rendering a = AccValidation [LiquidError] a data VarIndex ObjectIndex :: Text -> VarIndex ArrayIndex :: Int -> VarIndex -- | Interpret the raw data if it is ok interpret :: Value -> [Expr] -> Rendering Text -- | Interpret function - for use in testing the lib interpretWithJson :: Value -> Text -> Rendering Text -- | Run the templateParser on input text, force partial results to -- terminate with Failure parseTemplate :: Text -> IResult Text [Expr] -- | Rendering types -- -- Main template block rendering fn renderTemplate :: Value -> Expr -> Rendering Text templateP :: Prism' Text [Expr] -- | Parse an entire template into chunks templateParser :: Parser [Expr]