packages feed

express 1.0.6 → 1.0.8

raw patch · 5 files changed

+58/−5 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Data.Express.Utils.TH: toBounded :: Type -> Type
+ Data.Express.Utils.TH: toBoundedQ :: TypeQ -> TypeQ
+ Data.Express.Utils.TH: unboundVars :: Type -> [Name]

Files

changelog.md view
@@ -2,6 +2,16 @@ =====================  +v1.0.8+------++* `Data.Express.Express.Derive`:+  fix generation of `-:` and `->:` in earlier GHC's.++* `Data.Express.Utils.TH`:+  add `unboundVars`, `toBounded` and `toBoundedQ`.++ v1.0.6 ------ 
express.cabal view
@@ -1,6 +1,6 @@ -- Cabal file for express name: express-version: 1.0.6+version: 1.0.8 synopsis: Dynamically-typed expressions involving function application and variables. description:   Express is a library for manipulating dynamically typed Haskell expressions.@@ -63,7 +63,7 @@ source-repository this   type:           git   location:       https://github.com/rudymatela/express-  tag:            v1.0.6+  tag:            v1.0.8  library   exposed-modules:     Data.Express
src/Data/Express/Express/Derive.hs view
@@ -22,6 +22,7 @@ import Data.Express.Utils.TH import Data.Express.Utils.List import Data.Express.Utils.String+import Language.Haskell.TH.Lib  -- | Derives an 'Express' instance for the given type 'Name'. --@@ -94,8 +95,13 @@   vd <- [d| $(varP name) = const |]   return $ td:vd   where-  theT  =  [t| $(theFunT) -> $(last vars) -> $(theFunT) |]+  theT  =  bind [t| $(theFunT) -> $(last vars) -> $(theFunT) |]   theFunT  =  foldr1 funT vars   funT t1 t2  =  [t| $(t1) -> $(t2) |]   vars  =  map (varT . mkName) . take (n+1) . primeCycle $ map (:"") ['a'..'z']   name  =  mkName $ "-" ++ replicate n '>' ++ ":"+#if __GLASGOW_HASKELL__ >= 800+  bind  =  id -- unbound variables are automatically bound+#else+  bind  =  toBoundedQ+#endif
src/Data/Express/Utils/TH.hs view
@@ -29,6 +29,9 @@   , (|=>|)   , (|++|)   , whereI+  , unboundVars+  , toBounded+  , toBoundedQ   , module Language.Haskell.TH   ) where@@ -36,6 +39,7 @@ import Control.Monad import Data.List import Language.Haskell.TH+import Language.Haskell.TH.Lib  deriveWhenNeeded :: Name -> (Name -> DecsQ) -> Name -> DecsQ deriveWhenNeeded  =  deriveWhenNeededX False@@ -362,3 +366,36 @@   case mn of     Just n -> return n     Nothing -> fail $ "lookupValN: cannot find " ++ s+++-- | Lists all unbound variables in a type.+--   This intentionally excludes the 'ForallT' constructor.+unboundVars :: Type -> [Name]+unboundVars (VarT n)          =  [n]+unboundVars (AppT t1 t2)      =  nubMerge (unboundVars t1) (unboundVars t2)+unboundVars (SigT t _)        =  unboundVars t+unboundVars (ForallT vs _ t)  =  unboundVars t \\ map nm vs+  where+#if __GLASGOW_HASKELL__ < 900+  nm (PlainTV n)     =  n+  nm (KindedTV n _)  =  n+#else+  nm (PlainTV n _)     =  n+  nm (KindedTV n _ _)  =  n+#endif+unboundVars _                 =  []+++-- | Binds all unbound variables using a 'ForallT' constructor.+--   (cf. 'unboundVars')+toBounded :: Type -> Type+#if __GLASGOW_HASKELL__ < 900+toBounded t  =  ForallT [PlainTV n | n <- unboundVars t] [] t+#else+toBounded t  =  ForallT [PlainTV n SpecifiedSpec | n <- unboundVars t] [] t+#endif+++-- | Same as toBounded but lifted over 'Q'+toBoundedQ :: TypeQ -> TypeQ+toBoundedQ  =  liftM toBounded
test/express-derive.hs view
@@ -3,8 +3,8 @@ {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE DeriveDataTypeable #-} -import Test-+import Test hiding ((-:), (->:))+-- -: and ->: should be generated by deriveExpress  data Choice  =  Ae | Bee | Cee deriving (Show, Eq, Typeable) data Peano  =  Zero | Succ Peano deriving (Show, Eq, Typeable)