packages feed

lift-generics 0.1.2 → 0.1.3

raw patch · 5 files changed

+59/−10 lines, 5 filesdep ~template-haskellPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: template-haskell

API changes (from Hackage documentation)

+ Language.Haskell.TH.Lift.Generics: genericLiftTyped :: (Generic a, GLift (Rep a)) => a -> Q (TExp a)
+ Language.Haskell.TH.Lift.Generics: genericLiftTypedWithPkg :: (Generic a, GLift (Rep a)) => String -> a -> Q (TExp a)

Files

CHANGELOG.md view
@@ -1,3 +1,6 @@+### 0.1.3 [2019.11.26]+* Add `genericLiftTyped` and `genericLiftTypedWithPkg`.+ ### 0.1.2 * Add a case for `V1` (i.e., empty data types), which diverges in the way   you'd expect.
lift-generics.cabal view
@@ -1,5 +1,5 @@ name:                lift-generics-version:             0.1.2+version:             0.1.3 synopsis:            GHC.Generics-based Language.Haskell.TH.Syntax.lift implementation description:         This package provides a "GHC.Generics"-based @genericLiftWithPkg@                      function (intended for GHC 7.10 and earlier), as well as a@@ -38,6 +38,10 @@                    , GHC == 7.10.3                    , GHC == 8.0.2                    , GHC == 8.2.2+                   , GHC == 8.4.4+                   , GHC == 8.6.5+                   , GHC == 8.8.1+                   , GHC == 8.10.1 extra-source-files:  CHANGELOG.md, README.md cabal-version:       >=1.10 @@ -50,7 +54,7 @@   build-depends:       base             >= 4.3 && < 5                      , generic-deriving >= 1.9 && < 2                      , ghc-prim-                     , template-haskell >= 2.4 && < 2.13+                     , template-haskell >= 2.4 && < 2.17   hs-source-dirs:      src   default-language:    Haskell2010   ghc-options:         -Wall@@ -66,7 +70,8 @@                      , generic-deriving >= 1.9   && < 2                      , hspec            >= 2     && < 3                      , lift-generics-                     , template-haskell >= 2.4   && < 2.13+                     , template-haskell >= 2.4   && < 2.17+  build-tool-depends:  hspec-discover:hspec-discover   hs-source-dirs:      tests   default-language:    Haskell2010   ghc-options:         -Wall -threaded -rtsopts
src/Language/Haskell/TH/Lift/Generics.hs view
@@ -20,8 +20,12 @@ -} module Language.Haskell.TH.Lift.Generics (       genericLiftWithPkg+#if MIN_VERSION_template_haskell(2,9,0)+    , genericLiftTypedWithPkg+#endif #if __GLASGOW_HASKELL__ >= 711     , genericLift+    , genericLiftTyped #endif     , GLift(..)     , GLiftDatatype(..)@@ -103,6 +107,12 @@ genericLiftWithPkg :: (Generic a, GLift (Rep a)) => String -> a -> Q Exp genericLiftWithPkg pkg = glift pkg . from +#if MIN_VERSION_template_haskell(2,9,0)+-- | Like 'genericLiftWithPkg', but returns a 'TExp' instead of an 'Exp'.+genericLiftTypedWithPkg :: (Generic a, GLift (Rep a)) => String -> a -> Q (TExp a)+genericLiftTypedWithPkg pkg = unsafeTExpCoerce . genericLiftWithPkg pkg+#endif+ #if __GLASGOW_HASKELL__ >= 711 -- | "GHC.Generics"-based 'lift' implementation. Only available on GHC 8.0 and later -- due to API limitations of earlier GHC versions.@@ -137,6 +147,10 @@ -- @ genericLift :: (Generic a, GLift (Rep a)) => a -> Q Exp genericLift = glift "" . from++-- | Like 'genericLift', but returns a 'TExp' instead of an 'Exp'.+genericLiftTyped :: (Generic a, GLift (Rep a)) => a -> Q (TExp a)+genericLiftTyped = unsafeTExpCoerce . genericLift #endif  -- | Class of generic representation types which can be converted to Template
tests/LiftGenericsSpec.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE TemplateHaskell #-}  {-|@@ -10,7 +11,7 @@ -} module LiftGenericsSpec (main, spec) where -import Language.Haskell.TH.Syntax (lift)+import Language.Haskell.TH.Syntax (Lift(..)) import Test.Hspec (Spec, hspec, describe, it, parallel, shouldBe) import Types (Unit(..), p, s, u) @@ -35,3 +36,11 @@     describe "Unboxed" $         it description $             u `shouldBe` $(lift u)+#if MIN_VERSION_template_haskell(2,16,0)+    describe "genericLiftTyped" $+        it "should do what you expect" $ do+            Unit `shouldBe` $$(liftTyped Unit)+            p    `shouldBe` $$(liftTyped p)+            s    `shouldBe` $$(liftTyped s)+            u    `shouldBe` $$(liftTyped u)+#endif
tests/Types.hs view
@@ -21,7 +21,11 @@  import GHC.Exts -import Language.Haskell.TH.Lift.Generics (genericLiftWithPkg)+import Language.Haskell.TH.Lift.Generics ( genericLiftWithPkg+#if MIN_VERSION_template_haskell(2,16,0)+                                         , genericLiftTyped+#endif+                                         ) import Language.Haskell.TH.Syntax (Lift(..))  import Prelude ()@@ -29,10 +33,16 @@  data Unit = Unit   deriving (Eq, Ord, Show)+$(deriveAll ''Unit)+ data Product a b c d = Product a b c d   deriving (Eq, Ord, Show)+$(deriveAll ''Product)+ data Sum a b = Inl a | Inr b   deriving (Eq, Ord, Show)+$(deriveAll ''Sum)+ data Unboxed a    = Unboxed a #if MIN_VERSION_template_haskell(2,11,0)@@ -43,6 +53,7 @@              Int#              Word#   deriving (Eq, Ord, Show)+$(deriveAll ''Unboxed)  p :: Product Char Int Bool String p = Product 'a' 1 True "b"@@ -65,17 +76,24 @@  instance Lift Unit where     lift = genericLiftWithPkg pkgKey+#if MIN_VERSION_template_haskell(2,16,0)+    liftTyped = genericLiftTyped+#endif  instance (Lift a, Lift b, Lift c, Lift d) => Lift (Product a b c d) where     lift = genericLiftWithPkg pkgKey+#if MIN_VERSION_template_haskell(2,16,0)+    liftTyped = genericLiftTyped+#endif  instance (Lift a, Lift b) => Lift (Sum a b) where     lift = genericLiftWithPkg pkgKey+#if MIN_VERSION_template_haskell(2,16,0)+    liftTyped = genericLiftTyped+#endif  instance Lift a => Lift (Unboxed a) where     lift = genericLiftWithPkg pkgKey--$(deriveAll ''Unit)-$(deriveAll ''Product)-$(deriveAll ''Sum)-$(deriveAll ''Unboxed)+#if MIN_VERSION_template_haskell(2,16,0)+    liftTyped = genericLiftTyped+#endif