ginger 0.1.3.0 → 0.1.4.0
raw patch · 2 files changed
+30/−1 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Text.Ginger.GVal: (~>) :: ToGVal m a => Text -> a -> Pair m
+ Text.Ginger.GVal: dict :: [Pair m] -> GVal m
+ Text.Ginger.GVal: instance (Text.Ginger.GVal.ToGVal m a, Text.Ginger.GVal.ToGVal m b) => Text.Ginger.GVal.ToGVal m (a, b)
+ Text.Ginger.GVal: instance (Text.Ginger.GVal.ToGVal m a, Text.Ginger.GVal.ToGVal m b, Text.Ginger.GVal.ToGVal m c) => Text.Ginger.GVal.ToGVal m (a, b, c)
+ Text.Ginger.GVal: instance (Text.Ginger.GVal.ToGVal m a, Text.Ginger.GVal.ToGVal m b, Text.Ginger.GVal.ToGVal m c, Text.Ginger.GVal.ToGVal m d) => Text.Ginger.GVal.ToGVal m (a, b, c, d)
+ Text.Ginger.GVal: type Pair m = (Text, GVal m)
Files
- ginger.cabal +1/−1
- src/Text/Ginger/GVal.hs +29/−0
ginger.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: ginger-version: 0.1.3.0+version: 0.1.4.0 synopsis: An implementation of the Jinja2 template language in Haskell description: Ginger is Jinja, minus the most blatant pythonisms. Wants to be feature complete, but isn't quite there yet.
src/Text/Ginger/GVal.hs view
@@ -1,6 +1,7 @@ {-#LANGUAGE OverloadedStrings #-} {-#LANGUAGE MultiParamTypeClasses #-} {-#LANGUAGE FlexibleInstances #-}+{-#LANGUAGE ScopedTypeVariables #-} -- | GVal is a generic unitype value, representing the kind of values that -- Ginger can understand.@@ -224,6 +225,34 @@ , asNumber = Just x , isNull = False }++instance (ToGVal m a, ToGVal m b) => ToGVal m (a, b) where+ toGVal (a, b) = toGVal ([ toGVal a, toGVal b ] :: [GVal m])++instance (ToGVal m a, ToGVal m b, ToGVal m c) => ToGVal m (a, b, c) where+ toGVal (a, b, c) = toGVal ([ toGVal a, toGVal b, toGVal c ] :: [GVal m])++instance (ToGVal m a, ToGVal m b, ToGVal m c, ToGVal m d) => ToGVal m (a, b, c, d) where+ toGVal (a, b, c, d) = toGVal ([ toGVal a, toGVal b, toGVal c, toGVal d ] :: [GVal m])++-- * Convenience API for constructing heterogenous dictionaries.+--+-- Example usage:+--+-- > context :: GVal m+-- > context = dict [ "number" ~> (15 :: Int), "name" ~> ("Joe" :: String) ]++-- | A key/value pair, used for constructing dictionary GVals using a+-- compact syntax.+type Pair m = (Text, GVal m)++-- | Construct a dictionary GVal from a list of pairs.+dict :: [Pair m] -> GVal m+dict = toGVal . HashMap.fromList++-- | Construct a pair from a key and a value.+(~>) :: ToGVal m a => Text -> a -> Pair m+k ~> v = (k, toGVal v) -- | Silly helper function, needed to bypass the default 'Show' instance of -- 'Scientific' in order to make integral 'Scientific's look like integers.