Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- newtype Context a = Context {
- unContext :: ContextFunction a
- type ContextFunction a = String -> TemplateRunner a (ContextValue a)
- getContext :: Identifier -> Compiler (Context a)
- itemFilePath :: Item a -> FilePath
- data TemplateState a = TemplateState {
- tplContextStack :: [(Context a, Context a)]
- tplItemStack :: [Item a]
- tplCallStack :: [String]
- type TemplateRunner a b = StateT (TemplateState a) Compiler b
- tplItem :: TemplateRunner a (Item a)
- tplModifyItem :: (Item a -> TemplateRunner a (Item a)) -> TemplateRunner a ()
- tplReplaceItem :: Item a -> TemplateRunner a ()
- tplPopItem :: TemplateRunner a (Item a)
- tplPopBody :: TemplateRunner a a
- tplPushItem :: Item a -> TemplateRunner a ()
- tplWithItem :: Item a -> TemplateRunner a b -> TemplateRunner a b
- tplContext :: TemplateRunner a (Context a)
- tplPushContext :: Context a -> TemplateRunner a ()
- tplPopContext :: TemplateRunner a (Context a)
- tplWithContext :: Context a -> TemplateRunner a b -> TemplateRunner a b
- tplGet :: FromValue v a => String -> TemplateRunner a v
- tplGetWithItemContext :: FromValue v a => Item a -> Context a -> String -> TemplateRunner a v
- tplPut :: Context a -> TemplateRunner a ()
- tplWithCall :: String -> TemplateRunner a b -> TemplateRunner a b
- tplWithPos :: (x -> SourcePos) -> (x -> TemplateRunner a b) -> x -> TemplateRunner a b
- tplWithField :: String -> TemplateRunner a b -> TemplateRunner a b
- tplFail :: String -> TemplateRunner a b
- tplTried :: String -> TemplateRunner a b
- tplTrace :: TemplateRunner a [String]
- tplTraced :: String -> TemplateRunner a String
- field :: IntoValue v a => String -> (Item a -> TemplateRunner a v) -> Context a
- missingField :: Context a
- constField :: IntoValue v a => String -> v -> Context a
- itemsField :: String -> Context a -> [Item a] -> Context a
- mapField :: (FromValue v a, IntoValue w a) => (v -> w) -> Context a -> Context a
- bindField :: (FromValue v a, IntoValue w a) => (v -> TemplateRunner a w) -> Context a -> Context a
- composeField :: Context a -> Context a -> Context a
- hashMapField :: IntoValue v a => HashMap String v -> Context a
- forItemField :: IntoValue v a => String -> [Identifier] -> (Item a -> TemplateRunner a v) -> Context a
- functionField :: (FromValue v a, IntoValue w a) => String -> (v -> TemplateRunner a w) -> Context a
- functionField2 :: (FromValue v a, FromValue x a, IntoValue w a) => String -> (v -> x -> TemplateRunner a w) -> Context a
- functionField3 :: (FromValue v a, FromValue x a, FromValue y a, IntoValue w a) => String -> (v -> x -> y -> TemplateRunner a w) -> Context a
- functionField4 :: (FromValue v a, FromValue x a, FromValue y a, FromValue z a, IntoValue w a) => String -> (v -> x -> y -> z -> TemplateRunner a w) -> Context a
- class IntoContext v a where
- intoContext :: v -> Context a
- data ContextValue a
- = EmptyValue
- | UndefinedValue String (Item a) [String] [String]
- | ContextValue (Context a)
- | ListValue [ContextValue a]
- | BoolValue Bool
- | StringValue String
- | DoubleValue Double
- | IntValue Int
- | FunctionValue (ContextValue a -> TemplateRunner a (ContextValue a))
- | BlockValue Block
- | ItemValue (Item a)
- | ThunkValue (TemplateRunner a (ContextValue a))
- | PairValue (ContextValue a, ContextValue a)
- type FunctionValue v w a = v -> TemplateRunner a w
- type FunctionValue2 v x w a = v -> FunctionValue x w a
- type FunctionValue3 v x y w a = v -> FunctionValue2 x y w a
- type FunctionValue4 v x y z w a = v -> FunctionValue3 x y z w a
- itemValue :: Context a -> Item a -> ContextValue a
- class IntoValue' (flag :: Bool) v a where
- intoValue' :: Proxy flag -> v -> ContextValue a
- type family FString a :: Bool where ...
- class IntoValue v a where
- intoValue :: v -> ContextValue a
- class FromValue v a where
- fromValue :: ContextValue a -> TemplateRunner a v
- class FromValue' (flag :: Bool) v a where
- fromValue' :: Proxy flag -> ContextValue a -> TemplateRunner a v
Documentation
Instances
Monoid (Context a) Source # | |
Semigroup (Context a) Source # | |
FromValue (Context a) a Source # | |
Defined in Hakyllbars.Context fromValue :: ContextValue a -> TemplateRunner a (Context a) Source # | |
IntoContext (Context a) a Source # | |
Defined in Hakyllbars.Context intoContext :: Context a -> Context a Source # | |
IntoValue (Context a) a Source # | |
Defined in Hakyllbars.Context intoValue :: Context a -> ContextValue a Source # |
type ContextFunction a = String -> TemplateRunner a (ContextValue a) Source #
getContext :: Identifier -> Compiler (Context a) Source #
itemFilePath :: Item a -> FilePath Source #
data TemplateState a Source #
TemplateState | |
|
Instances
type TemplateRunner a b = StateT (TemplateState a) Compiler b Source #
tplItem :: TemplateRunner a (Item a) Source #
tplModifyItem :: (Item a -> TemplateRunner a (Item a)) -> TemplateRunner a () Source #
tplReplaceItem :: Item a -> TemplateRunner a () Source #
tplPopItem :: TemplateRunner a (Item a) Source #
tplPopBody :: TemplateRunner a a Source #
tplPushItem :: Item a -> TemplateRunner a () Source #
tplWithItem :: Item a -> TemplateRunner a b -> TemplateRunner a b Source #
tplContext :: TemplateRunner a (Context a) Source #
tplPushContext :: Context a -> TemplateRunner a () Source #
tplPopContext :: TemplateRunner a (Context a) Source #
tplWithContext :: Context a -> TemplateRunner a b -> TemplateRunner a b Source #
Place context within a given scope.
tplGet :: FromValue v a => String -> TemplateRunner a v Source #
Get a value from the context by name and convert it.
tplGetWithItemContext :: FromValue v a => Item a -> Context a -> String -> TemplateRunner a v Source #
Get a value from a specific item's context by name and convert it.
tplPut :: Context a -> TemplateRunner a () Source #
Place context in global scope.
tplWithCall :: String -> TemplateRunner a b -> TemplateRunner a b Source #
Perform an action within the scope of a call.
tplWithPos :: (x -> SourcePos) -> (x -> TemplateRunner a b) -> x -> TemplateRunner a b Source #
tplWithField :: String -> TemplateRunner a b -> TemplateRunner a b Source #
Perform an action within the scope of a field call.
tplFail :: String -> TemplateRunner a b Source #
Fail with an error message and trace.
tplTried :: String -> TemplateRunner a b Source #
Fail with a no-result message and trace.
tplTrace :: TemplateRunner a [String] Source #
Return the current call stack, with the most recent call first.
tplTraced :: String -> TemplateRunner a String Source #
Get a formatted trace message with the most recent call first.
field :: IntoValue v a => String -> (Item a -> TemplateRunner a v) -> Context a Source #
Apply f
to an item if key
is requested.
missingField :: Context a Source #
Reports missing field.
constField :: IntoValue v a => String -> v -> Context a Source #
Const-valued field, returns the same val
per key
.
itemsField :: String -> Context a -> [Item a] -> Context a Source #
Creates a field containing a list of items.
mapField :: (FromValue v a, IntoValue w a) => (v -> w) -> Context a -> Context a Source #
Mapping of function g
after context f
.
bindField :: (FromValue v a, IntoValue w a) => (v -> TemplateRunner a w) -> Context a -> Context a Source #
Binding of function g
after context f
.
composeField :: Context a -> Context a -> Context a Source #
Alternation of context g
after context f
.
hashMapField :: IntoValue v a => HashMap String v -> Context a Source #
Lookup of val
by key
into provided HashMap
.
forItemField :: IntoValue v a => String -> [Identifier] -> (Item a -> TemplateRunner a v) -> Context a Source #
functionField :: (FromValue v a, IntoValue w a) => String -> (v -> TemplateRunner a w) -> Context a Source #
functionField2 :: (FromValue v a, FromValue x a, IntoValue w a) => String -> (v -> x -> TemplateRunner a w) -> Context a Source #
functionField3 :: (FromValue v a, FromValue x a, FromValue y a, IntoValue w a) => String -> (v -> x -> y -> TemplateRunner a w) -> Context a Source #
functionField4 :: (FromValue v a, FromValue x a, FromValue y a, FromValue z a, IntoValue w a) => String -> (v -> x -> y -> z -> TemplateRunner a w) -> Context a Source #
class IntoContext v a where Source #
intoContext :: v -> Context a Source #
Instances
IntoContext Object a Source # | |
Defined in Hakyllbars.Context intoContext :: Object -> Context a Source # | |
IntoContext (Context a) a Source # | |
Defined in Hakyllbars.Context intoContext :: Context a -> Context a Source # | |
IntoValue v a => IntoContext [(String, v)] a Source # | |
Defined in Hakyllbars.Context intoContext :: [(String, v)] -> Context a Source # | |
IntoValue v a => IntoContext (HashMap String v) a Source # | |
Defined in Hakyllbars.Context |
data ContextValue a Source #
ContextValues can hold certain types of data within a context.
EmptyValue | |
UndefinedValue String (Item a) [String] [String] | |
ContextValue (Context a) | |
ListValue [ContextValue a] | |
BoolValue Bool | |
StringValue String | |
DoubleValue Double | |
IntValue Int | |
FunctionValue (ContextValue a -> TemplateRunner a (ContextValue a)) | |
BlockValue Block | |
ItemValue (Item a) | |
ThunkValue (TemplateRunner a (ContextValue a)) | |
PairValue (ContextValue a, ContextValue a) |
Instances
Show (ContextValue a) Source # | |
Defined in Hakyllbars.Context showsPrec :: Int -> ContextValue a -> ShowS # show :: ContextValue a -> String # showList :: [ContextValue a] -> ShowS # | |
FromValue (ContextValue a) a Source # | |
Defined in Hakyllbars.Context fromValue :: ContextValue a -> TemplateRunner a (ContextValue a) Source # | |
IntoValue (ContextValue a) a Source # | |
Defined in Hakyllbars.Context intoValue :: ContextValue a -> ContextValue a Source # | |
IntoValue (TemplateRunner a (ContextValue a)) a Source # | |
Defined in Hakyllbars.Context intoValue :: TemplateRunner a (ContextValue a) -> ContextValue a Source # |
type FunctionValue v w a = v -> TemplateRunner a w Source #
type FunctionValue2 v x w a = v -> FunctionValue x w a Source #
type FunctionValue3 v x y w a = v -> FunctionValue2 x y w a Source #
type FunctionValue4 v x y z w a = v -> FunctionValue3 x y z w a Source #
class IntoValue' (flag :: Bool) v a where Source #
intoValue' :: Proxy flag -> v -> ContextValue a Source #
Instances
IntoValue' 'True String a Source # | |
Defined in Hakyllbars.Context intoValue' :: Proxy 'True -> String -> ContextValue a Source # | |
IntoValue v a => IntoValue' 'False [v] a Source # | |
Defined in Hakyllbars.Context intoValue' :: Proxy 'False -> [v] -> ContextValue a Source # |
class IntoValue v a where Source #
Inject a concrete type v
into a ContextValue a
.
intoValue :: v -> ContextValue a Source #
Instances
class FromValue v a where Source #
Extract a concrete value of type v
from a ContextValue a
.
fromValue :: ContextValue a -> TemplateRunner a v Source #
Instances
class FromValue' (flag :: Bool) v a where Source #
fromValue' :: Proxy flag -> ContextValue a -> TemplateRunner a v Source #
Instances
FromValue' 'True String a Source # | |
Defined in Hakyllbars.Context fromValue' :: Proxy 'True -> ContextValue a -> TemplateRunner a String Source # | |
FromValue v a => FromValue' 'False [v] a Source # | |
Defined in Hakyllbars.Context fromValue' :: Proxy 'False -> ContextValue a -> TemplateRunner a [v] Source # |