packages feed

th-abstraction 0.4.5.0 → 0.5.0.0

raw patch · 6 files changed

+95/−8 lines, 6 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Language.Haskell.TH.Datatype: TypeData :: DatatypeVariant

Files

ChangeLog.md view
@@ -1,5 +1,12 @@ # Revision history for th-abstraction +## 0.5.0.0 -- 2023.02.27+* Support the `TypeData` language extension added in GHC 9.6. The+  `DatatypeVariant` data type now has a separate `TypeData` constructor to+  represent `type data` declarations.+* Add a `Lift` instance for `th-abstraction`'s compatibility shim for+  `Specificity` when building with pre-9.0 versions of GHC.+ ## 0.4.5.0 -- 2022.09.12 * Fix a bug in which data family declarations with interesting return kinds   (e.g., `data family F :: Type -> Type`) would be reified incorrectly when
src/Language/Haskell/TH/Datatype.hs view
@@ -207,10 +207,31 @@  -- | Possible variants of data type declarations. data DatatypeVariant-  = Datatype        -- ^ Type declared with @data@-  | Newtype         -- ^ Type declared with @newtype@-  | DataInstance    -- ^ Type declared with @data instance@-  | NewtypeInstance -- ^ Type declared with @newtype instance@+  = Datatype        -- ^ Type declared with @data@.+  | Newtype         -- ^ Type declared with @newtype@.+                    --+                    --   A 'DatatypeInfo' that uses 'Newtype' will uphold the+                    --   invariant that there will be exactly one+                    --   'ConstructorInfo' in the 'datatypeCons'.+  | DataInstance    -- ^ Type declared with @data instance@.+  | NewtypeInstance -- ^ Type declared with @newtype instance@.+                    --+                    --   A 'DatatypeInfo' that uses 'NewtypeInstance' will+                    --   uphold the invariant that there will be exactly one+                    --   'ConstructorInfo' in the 'datatypeCons'.+  | TypeData        -- ^ Type declared with @type data@.+                    --+                    --   A 'DatatypeInfo' that uses 'TypeData' will uphold the+                    --   following invariants:+                    --+                    --   * The 'datatypeContext' will be empty.+                    --+                    --   * None of the 'constructorVariant's in any of the+                    --     'datatypeCons' will be 'RecordConstructor'.+                    --+                    --   * Each of the 'constructorStrictness' values in each+                    --     of the 'datatypeCons' will be equal to+                    --     'notStrictAnnot'.   deriving (Show, Read, Eq, Ord, Typeable, Data #ifdef HAS_GENERICS            ,Generic@@ -656,6 +677,10 @@ normalizeDecFor :: IsReifiedDec -> Dec -> Q DatatypeInfo normalizeDecFor isReified dec =   case dec of+#if MIN_VERSION_template_haskell(2,20,0)+    TypeDataD name tyvars mbKind cons ->+      normalizeDataD [] name tyvars mbKind cons TypeData+#endif #if MIN_VERSION_template_haskell(2,12,0)     NewtypeD context name tyvars mbKind con _derives ->       normalizeDataD context name tyvars mbKind [con] Newtype@@ -778,6 +803,7 @@     Newtype         -> False     DataInstance    -> True     NewtypeInstance -> True+    TypeData        -> False  bndrParams :: [TyVarBndr_ flag] -> [Type] bndrParams = map $ elimTV VarT (\n k -> SigT (VarT n) k)
src/Language/Haskell/TH/Datatype/TyVarBndr.hs view
@@ -11,6 +11,11 @@ {-# Language Trustworthy #-} #endif +#if __GLASGOW_HASKELL__ >= 800+#define HAS_TH_LIFT+{-# Language DeriveLift #-}+#endif+ {-| Module      : Language.Haskell.TH.Datatype.TyVarBndr Description : Backwards-compatible type variable binders@@ -102,6 +107,9 @@   deriving (Show, Eq, Ord, Typeable, Data #ifdef HAS_GENERICS            ,Generic+#endif+#ifdef HAS_TH_LIFT+           ,Lift #endif            ) 
test/Main.hs view
@@ -39,7 +39,7 @@ #endif  import           Language.Haskell.TH-import           Language.Haskell.TH.Datatype+import           Language.Haskell.TH.Datatype as Datatype import           Language.Haskell.TH.Datatype.TyVarBndr import           Language.Haskell.TH.Lib (starK) @@ -110,6 +110,9 @@      t70Test      t88Test      captureAvoidanceTest+#if MIN_VERSION_template_haskell(2,20,0)+     t100Test+#endif  adt1Test :: IO () adt1Test =@@ -1147,3 +1150,32 @@       wrongTy  = ForallT [plainTVSpecified a] [] (VarT a)   when (substTy == wrongTy) $     fail $ "applySubstitution captures during substitution"++#if MIN_VERSION_template_haskell(2,20,0)+t100Test :: IO ()+t100Test =+  $(do let expectedInfo =+             DatatypeInfo+               { datatypeName = ''T100+               , datatypeContext = []+               , datatypeVars = []+               , datatypeInstTypes = []+               , datatypeVariant = Datatype.TypeData+               , datatypeCons =+                   [ ConstructorInfo+                       { constructorName = ''MkT100+                       , constructorContext = []+                       , constructorVars = []+                       , constructorFields = []+                       , constructorStrictness = []+                       , constructorVariant = NormalConstructor }+                   ]+               }++       t100Info <- reifyDatatype ''T100+       validateDI t100Info expectedInfo++       mkT100Info <- reifyDatatype ''MkT100+       validateDI mkT100Info expectedInfo+   )+#endif
test/Types.hs view
@@ -9,9 +9,16 @@ #endif  #if __GLASGOW_HASKELL__ >= 800+{-# Language DataKinds #-}+# if __GLASGOW_HASKELL__ < 806 {-# Language TypeInType #-}+# endif #endif +#if MIN_VERSION_template_haskell(2,20,0)+{-# Language TypeData #-}+#endif+ {-| Module      : Types Description : Test cases for the th-abstraction package@@ -150,6 +157,10 @@  data T75 (k :: Type) where   MkT75 :: forall k (a :: k). Prox a -> T75 k+#endif++#if MIN_VERSION_template_haskell(2,20,0)+type data T100 = MkT100 #endif  -- We must define these here due to Template Haskell staging restrictions
th-abstraction.cabal view
@@ -1,5 +1,5 @@ name:                th-abstraction-version:             0.4.5.0+version:             0.5.0.0 synopsis:            Nicer interface for reified information about data types description:         This package normalizes variations in the interface for                      inspecting datatype information via Template Haskell@@ -17,7 +17,7 @@ build-type:          Simple extra-source-files:  ChangeLog.md README.md cabal-version:       >=1.10-tested-with:         GHC==9.2.2, GHC==9.0.2, GHC==8.10.7, GHC==8.8.4, GHC==8.6.5, GHC==8.4.4, GHC==8.2.2, GHC==8.0.2, GHC==7.10.3, GHC==7.8.4, GHC==7.6.3, GHC==7.4.2, GHC==7.2.2, GHC==7.0.4+tested-with:         GHC==9.6.1, GHC==9.4.4, GHC==9.2.6, GHC==9.0.2, GHC==8.10.7, GHC==8.8.4, GHC==8.6.5, GHC==8.4.4, GHC==8.2.2, GHC==8.0.2, GHC==7.10.3, GHC==7.8.4, GHC==7.6.3, GHC==7.4.2, GHC==7.2.2, GHC==7.0.4  source-repository head   type: git@@ -29,7 +29,7 @@   other-modules:       Language.Haskell.TH.Datatype.Internal   build-depends:       base             >=4.3   && <5,                        ghc-prim,-                       template-haskell >=2.5   && <2.20,+                       template-haskell >=2.5   && <2.21,                        containers       >=0.4   && <0.7   hs-source-dirs:      src   default-language:    Haskell2010@@ -47,3 +47,6 @@   build-depends:       th-abstraction, base, containers, template-haskell   hs-source-dirs:      test   default-language:    Haskell2010++  if impl(ghc >= 8.6)+    ghc-options:       -Wno-star-is-type