generic-deriving 1.11.1 → 1.11.2
raw patch · 8 files changed
+238/−22 lines, 8 filesdep ~generic-derivingdep ~template-haskellPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: generic-deriving, template-haskell
API changes (from Hackage documentation)
Files
- CHANGELOG.md +6/−0
- generic-deriving.cabal +6/−5
- src/Generics/Deriving/Enum.hs +96/−0
- src/Generics/Deriving/Eq.hs +45/−0
- src/Generics/Deriving/Show.hs +45/−0
- src/Generics/Deriving/TH.hs +13/−13
- src/Generics/Deriving/TH/Internal.hs +2/−2
- tests/TypeInTypeSpec.hs +25/−2
CHANGELOG.md view
@@ -1,3 +1,9 @@+# 1.11.2 [2017.04.10]+* Add `GEq`, `GShow`, `GEnum`, and `GIx` instances for the new data types+ in `Foreign.C.Types` (`CBool`) and `System.Posix.Types` (`CBlkSize`,+ `CBlkCnt`, `CClockId`, `CFsBlkCnt`, `CFsFilCnt`, `CId`, `CKey`, and `CTimer`)+ introduced in `base-4.10.0.0`+ # 1.11.1 [2016.09.10] * Fix Template Haskell regression involving data families * Convert examples to test suite
generic-deriving.cabal view
@@ -1,5 +1,5 @@ name: generic-deriving-version: 1.11.1+version: 1.11.2 synopsis: Generic programming library for generalised deriving. description: @@ -31,7 +31,8 @@ , GHC == 7.6.3 , GHC == 7.8.4 , GHC == 7.10.3- , GHC == 8.0.1+ , GHC == 8.0.2+ , GHC == 8.2.1 extra-source-files: CHANGELOG.md , README.md @@ -75,7 +76,7 @@ build-depends: containers >= 0.1 && < 0.6 , ghc-prim < 1- , template-haskell >= 2.4 && < 2.12+ , template-haskell >= 2.4 && < 2.13 default-language: Haskell2010 ghc-options: -Wall@@ -86,9 +87,9 @@ other-modules: ExampleSpec TypeInTypeSpec build-depends: base >= 4.3 && < 5- , generic-deriving == 1.11.1+ , generic-deriving , hspec >= 2 && < 3- , template-haskell >= 2.4 && < 2.12+ , template-haskell >= 2.4 && < 2.13 hs-source-dirs: tests default-language: Haskell2010 ghc-options: -Wall -threaded -rtsopts
src/Generics/Deriving/Enum.hs view
@@ -537,6 +537,46 @@ instance GEnum a => GEnum (ZipList a) where genum = genumDefault +#if MIN_VERSION_base(4,10,0)+instance GEnum CBool where+ genum = coerce (genum :: [HTYPE_BOOL])++# if defined(HTYPE_BLKSIZE_T)+instance GEnum CBlkSize where+ genum = coerce (genum :: [HTYPE_BLKSIZE_T])+# endif++# if defined(HTYPE_BLKCNT_T)+instance GEnum CBlkCnt where+ genum = coerce (genum :: [HTYPE_BLKCNT_T])+# endif++# if defined(HTYPE_CLOCKID_T)+instance GEnum CClockId where+ genum = coerce (genum :: [HTYPE_CLOCKID_T])+# endif++# if defined(HTYPE_FSBLKCNT_T)+instance GEnum CFsBlkCnt where+ genum = coerce (genum :: [HTYPE_FSBLKCNT_T])+# endif++# if defined(HTYPE_FSFILCNT_T)+instance GEnum CFsFilCnt where+ genum = coerce (genum :: [HTYPE_FSFILCNT_T])+# endif++# if defined(HTYPE_ID_T)+instance GEnum CId where+ genum = coerce (genum :: [HTYPE_ID_T])+# endif++# if defined(HTYPE_KEY_T)+instance GEnum CKey where+ genum = coerce (genum :: [HTYPE_KEY_T])+# endif+#endif+ -------------------------------------------------------------------------------- -- Generic Ix --------------------------------------------------------------------------------@@ -1051,4 +1091,60 @@ range = rangeDefault index = indexDefault inRange = inRangeDefault+#endif++#if MIN_VERSION_base(4,10,0)+instance GIx CBool where+ range = rangeEnum+ index = indexIntegral+ inRange = inRangeOrd++# if defined(HTYPE_BLKSIZE_T)+instance GIx CBlkSize where+ range = rangeEnum+ index = indexIntegral+ inRange = inRangeOrd+# endif++# if defined(HTYPE_BLKCNT_T)+instance GIx CBlkCnt where+ range = rangeEnum+ index = indexIntegral+ inRange = inRangeOrd+# endif++# if defined(HTYPE_CLOCKID_T)+instance GIx CClockId where+ range = rangeEnum+ index = indexIntegral+ inRange = inRangeOrd+# endif++# if defined(HTYPE_FSBLKCNT_T)+instance GIx CFsBlkCnt where+ range = rangeEnum+ index = indexIntegral+ inRange = inRangeOrd+# endif++# if defined(HTYPE_FSFILCNT_T)+instance GIx CFsFilCnt where+ range = rangeEnum+ index = indexIntegral+ inRange = inRangeOrd+# endif++# if defined(HTYPE_ID_T)+instance GIx CId where+ range = rangeEnum+ index = indexIntegral+ inRange = inRangeOrd+# endif++# if defined(HTYPE_KEY_T)+instance GIx CKey where+ range = rangeEnum+ index = indexIntegral+ inRange = inRangeOrd+# endif #endif
src/Generics/Deriving/Eq.hs view
@@ -576,3 +576,48 @@ instance GEq a => GEq (ZipList a) where geq = geqdefault++#if MIN_VERSION_base(4,10,0)+instance GEq CBool where+ geq = (==)++# if defined(HTYPE_BLKSIZE_T)+instance GEq CBlkSize where+ geq = (==)+# endif++# if defined(HTYPE_BLKCNT_T)+instance GEq CBlkCnt where+ geq = (==)+# endif++# if defined(HTYPE_CLOCKID_T)+instance GEq CClockId where+ geq = (==)+# endif++# if defined(HTYPE_FSBLKCNT_T)+instance GEq CFsBlkCnt where+ geq = (==)+# endif++# if defined(HTYPE_FSFILCNT_T)+instance GEq CFsFilCnt where+ geq = (==)+# endif++# if defined(HTYPE_ID_T)+instance GEq CId where+ geq = (==)+# endif++# if defined(HTYPE_KEY_T)+instance GEq CKey where+ geq = (==)+# endif++# if defined(HTYPE_TIMER_T)+instance GEq CTimer where+ geq = (==)+# endif+#endif
src/Generics/Deriving/Show.hs view
@@ -615,3 +615,48 @@ instance GShow a => GShow (ZipList a) where gshowsPrec = gshowsPrecdefault++#if MIN_VERSION_base(4,10,0)+instance GShow CBool where+ gshowsPrec = showsPrec++# if defined(HTYPE_BLKSIZE_T)+instance GShow CBlkSize where+ gshowsPrec = showsPrec+# endif++# if defined(HTYPE_BLKCNT_T)+instance GShow CBlkCnt where+ gshowsPrec = showsPrec+# endif++# if defined(HTYPE_CLOCKID_T)+instance GShow CClockId where+ gshowsPrec = showsPrec+# endif++# if defined(HTYPE_FSBLKCNT_T)+instance GShow CFsBlkCnt where+ gshowsPrec = showsPrec+# endif++# if defined(HTYPE_FSFILCNT_T)+instance GShow CFsFilCnt where+ gshowsPrec = showsPrec+# endif++# if defined(HTYPE_ID_T)+instance GShow CId where+ gshowsPrec = showsPrec+# endif++# if defined(HTYPE_KEY_T)+instance GShow CKey where+ gshowsPrec = showsPrec+# endif++# if defined(HTYPE_TIMER_T)+instance GShow CTimer where+ gshowsPrec = showsPrec+# endif+#endif
src/Generics/Deriving/TH.hs view
@@ -689,8 +689,8 @@ t', t'' :: Type t' = case gk of Gen1 _ (Just _kvName) ->--- See Note [Generic1 is polykinded on GHC 8.2]-#if __GLASGOW_HASKELL__ >= 801+-- See Note [Generic1 is polykinded in base-4.10]+#if MIN_VERSION_base(4,10,0) t #else substNameWithKind _kvName starK t@@ -1063,8 +1063,8 @@ -- Substitute kind * for any dropped kind variables let varTysExpSubst :: [Type]--- See Note [Generic1 is polykinded on GHC 8.2]-#if __GLASGOW_HASKELL__ >= 801+-- See Note [Generic1 is polykinded in base-4.10]+#if MIN_VERSION_base(4,10,0) varTysExpSubst = varTysExp #else varTysExpSubst = map (substNamesWithKindStar droppedKindVarNames) varTysExp@@ -1077,8 +1077,8 @@ (remainingTysExpSubst, droppedTysExpSubst) = splitAt remainingLength varTysExpSubst --- See Note [Generic1 is polykinded on GHC 8.2]-#if __GLASGOW_HASKELL__ < 801+-- See Note [Generic1 is polykinded in base-4.10]+#if !(MIN_VERSION_base(4,10,0)) -- If any of the dropped types were polykinded, ensure that there are of -- kind * after substituting * for the dropped kind variables. If not, -- throw an error.@@ -1104,8 +1104,8 @@ -- instance C (Fam [Char]) let varTysOrigSubst :: [Type] varTysOrigSubst =--- See Note [Generic1 is polykinded on GHC 8.2]-#if __GLASGOW_HASKELL__ >= 801+-- See Note [Generic1 is polykinded in base-4.10]+#if MIN_VERSION_base(4,10,0) id #else map (substNamesWithKindStar droppedKindVarNames)@@ -1185,7 +1185,7 @@ Then k gets specialized to *, which means that k should NOT show up in the RHS of a Rep1 type instance! To avoid this, make sure to substitute k with *.-See also Note [Generic1 is polykinded on GHC 8.2].+See also Note [Generic1 is polykinded in base-4.10]. Note [Arguments to generated type synonyms] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~@@ -1314,10 +1314,10 @@ explicit kind signatures, leaving it up to GHC's kind inference machinery to figure out the correct kinds. -Note [Generic1 is polykinded on GHC 8.2]+Note [Generic1 is polykinded in base-4.10] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Prior to GHC 8.2, Generic1 :: (* -> *) -> Constraint. This means that if a Generic1+Prior to base-4.10, Generic1 :: (* -> *) -> Constraint. This means that if a Generic1 instance is defined for a polykinded data type like so: data Proxy k (a :: k) = Proxy@@ -1329,6 +1329,6 @@ We must take great care to ensure that all occurrences of k are substituted with *, or else the generated instance will be ill kinded. -On GHC 8.2 and later, Generic1 :: (k -> *) -> Constraint. This means we don't have-to do this kind unification anymore! Hooray!+In base-4.10 and later, Generic1 :: (k -> *) -> Constraint. This means we don't have+to do any of this kind unification trickery anymore! Hooray! -}
src/Generics/Deriving/TH/Internal.hs view
@@ -536,8 +536,8 @@ case mbLastArgKindName of Nothing -> map tyVarBndrToType headRequiredTvbs Just _lakn ->--- See Note [Generic1 is polykinded on GHC 8.2] in Generics.Deriving.TH-#if __GLASGOW_HASKELL__ >= 801+-- See Note [Generic1 is polykinded in base-4.10] in Generics.Deriving.TH+#if MIN_VERSION_base(4,10,0) map tyVarBndrToType headRequiredTvbs #else map (substNameWithKindStarInTyVarBndr _lakn)
tests/TypeInTypeSpec.hs view
@@ -12,19 +12,42 @@ import Test.Hspec #if __GLASGOW_HASKELL__ >= 800-import Data.Proxy (Proxy)+import Data.Proxy (Proxy(..)) import Generics.Deriving.TH +# if MIN_VERSION_base(4,10,0)+import Generics.Deriving (Generic1(..))+# endif+ data TyCon x (a :: x) (b :: k) = TyCon k x (Proxy a) (TyCon x a b) $(deriveAll0And1 ''TyCon) data family TyFam x (a :: x) (b :: k) data instance TyFam x (a :: x) (b :: k) = TyFam k x (Proxy a) (TyFam x a b) $(deriveAll0And1 'TyFam)++# if MIN_VERSION_base(4,10,0)+gen1PolyKinds :: Generic1 f => f 'True -> Rep1 f 'True+gen1PolyKinds = from1+# endif #endif main :: IO () main = hspec spec spec :: Spec-spec = return ()+spec = parallel $ do+#if MIN_VERSION_base(4,10,0)+ describe "TyCon Bool 'False 'True" $+ it "has an appropriately kinded Generic1 instance" $+ let rep :: Rep1 (TyCon Bool 'False) 'True+ rep = gen1PolyKinds $ let x = TyCon True False Proxy x in x+ in seq rep () `shouldBe` ()+ describe "TyFam Bool 'False 'True" $+ it "has an appropriately kinded Generic1 instance" $+ let rep :: Rep1 (TyFam Bool 'False) 'True+ rep = gen1PolyKinds $ let x = TyFam True False Proxy x in x+ in seq rep () `shouldBe` ()+#else+ return ()+#endif