File: Renderf.hs

package info (click to toggle)
haskell-hstringtemplate 0.8.8-5
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 164 kB
  • sloc: haskell: 999; makefile: 2
file content (16 lines) | stat: -rw-r--r-- 575 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}
module Text.StringTemplate.Renderf ((|=), SEType(..)) where
import Text.StringTemplate.Base

class Stringable b => SEType b a where
    renderf :: StringTemplate b -> a
instance Stringable a => SEType a a where
    renderf = render
instance Stringable a => SEType a (StringTemplate a) where
    renderf = id
instance (ToSElem a, SEType b r) => SEType b ((String, a) -> r) where
    renderf x (k, v) = renderf $ setAttribute k v x

(|=) :: (Monad m) => a -> m a1 -> m (a, a1)
k |= v = return . (,) k =<< v
infixl 5 |=