hakyll/src/Hakyll/Web/Template/Context.hs

25 lines
752 B
Haskell
Raw Normal View History

2012-11-10 12:26:39 +00:00
--------------------------------------------------------------------------------
module Hakyll.Web.Template.Context
( Context
, field
) where
--------------------------------------------------------------------------------
import Control.Applicative (empty)
import Control.Arrow
import Hakyll.Core.Compiler
--------------------------------------------------------------------------------
type Context a = Compiler (String, a) String
--------------------------------------------------------------------------------
field :: String -> Compiler a String -> Context a
field key value = arr checkKey >>> empty ||| value
where
checkKey (k, x)
| k == key = Left ()
| otherwise = Right x