packages feed

th-lift 0.7.8 → 0.7.9

raw patch · 2 files changed

+41/−2 lines, 2 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Language.Haskell.TH.Lift: instance Language.Haskell.TH.Syntax.Lift a => Language.Haskell.TH.Syntax.Lift (Data.Functor.Const.Const a b)
+ Language.Haskell.TH.Lift: instance Language.Haskell.TH.Syntax.Lift a => Language.Haskell.TH.Syntax.Lift (Data.Functor.Identity.Identity a)
- Language.Haskell.TH.Lift: deriveLift' :: Info -> Q [Dec]
+ Language.Haskell.TH.Lift: deriveLift' :: [Role] -> Info -> Q [Dec]
- Language.Haskell.TH.Lift: deriveLiftMany' :: [Info] -> Q [Dec]
+ Language.Haskell.TH.Lift: deriveLiftMany' :: [([Role], Info)] -> Q [Dec]

Files

src/Language/Haskell/TH/Lift.hs view
@@ -28,9 +28,13 @@ import GHC.Prim (Char#) #endif /* !(MIN_VERSION_template_haskell(2,11,0)) */ +import Control.Applicative #if MIN_VERSION_template_haskell(2,8,0) import Data.Char (ord) #endif /* !(MIN_VERSION_template_haskell(2,8,0)) */+#if MIN_VERSION_base(4,8,0)+import Data.Functor.Identity+#endif #if !(MIN_VERSION_template_haskell(2,10,0)) import Data.Ratio (Ratio) #endif /* !(MIN_VERSION_template_haskell(2,10,0)) */@@ -46,19 +50,41 @@  -- | Derive Lift instances for the given datatype. deriveLift :: Name -> Q [Dec]+#if MIN_VERSION_template_haskell(2,9,0)+deriveLift name = do+  roles <- qReifyRoles name+  info <- reify name+  deriveLift' roles info+#else deriveLift = deriveLift' <=< reify+#endif  -- | Derive Lift instances for many datatypes. deriveLiftMany :: [Name] -> Q [Dec]+#if MIN_VERSION_template_haskell(2,9,0)+deriveLiftMany names = do+  roles <- mapM qReifyRoles names+  infos <- mapM reify names+  deriveLiftMany' (zip roles infos)+#else deriveLiftMany = deriveLiftMany' <=< mapM reify+#endif  -- | Obtain Info values through a custom reification function. This is useful -- when generating instances for datatypes that have not yet been declared.+#if MIN_VERSION_template_haskell(2,9,0)+deriveLift' :: [Role] -> Info -> Q [Dec]+deriveLift' roles = fmap (:[]) . deriveLiftOne roles++deriveLiftMany' :: [([Role], Info)] -> Q [Dec]+deriveLiftMany' = mapM (uncurry deriveLiftOne)+#else deriveLift' :: Info -> Q [Dec] deriveLift' = fmap (:[]) . deriveLiftOne  deriveLiftMany' :: [Info] -> Q [Dec] deriveLiftMany' = mapM deriveLiftOne+#endif  -- | Generates a lambda expresson which behaves like 'lift' (without requiring -- a 'Lift' instance). Example:@@ -76,12 +102,17 @@ makeLift' :: Info -> Q Exp makeLift' i = withInfo i $ \_ n _ cons -> makeLiftOne n cons +#if MIN_VERSION_template_haskell(2,9,0)+deriveLiftOne :: [Role] -> Info -> Q Dec+deriveLiftOne roles i = withInfo i liftInstance+#else deriveLiftOne :: Info -> Q Dec deriveLiftOne i = withInfo i liftInstance+#endif   where     liftInstance dcx n vs cons = do #if MIN_VERSION_template_haskell(2,9,0)-      roles <- qReifyRoles n+      -- roles <- qReifyRoles n       -- Compute the set of phantom variables.       let phvars = catMaybes $             zipWith (\v role -> if role == PhantomR then Just v else Nothing)@@ -261,3 +292,11 @@ instance Integral a => Lift (Ratio a) where   lift x = return (LitE (RationalL (toRational x))) #endif++#if MIN_VERSION_base(4,8,0)+instance Lift a => Lift (Identity a) where+  lift = appE (conE 'Identity) . lift . runIdentity+#endif++instance Lift a => Lift (Const a b) where+  lift = appE (conE 'Const) . lift . getConst
th-lift.cabal view
@@ -1,5 +1,5 @@ Name:               th-lift-Version:            0.7.8+Version:            0.7.9 Cabal-Version:      >= 1.8 License:            BSD3 License-Files:      COPYING, BSD3, GPL-2