Hello community,
here is the log from the commit of package ghc-generic-deriving for
openSUSE:Factory checked in at 2020-10-23 15:13:55
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-generic-deriving (Old)
and /work/SRC/openSUSE:Factory/.ghc-generic-deriving.new.3463 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-generic-deriving"
Fri Oct 23 15:13:55 2020 rev:17 rq:842745 version:1.14
Changes:
--------
---
/work/SRC/openSUSE:Factory/ghc-generic-deriving/ghc-generic-deriving.changes
2020-09-15 16:17:51.661999543 +0200
+++
/work/SRC/openSUSE:Factory/.ghc-generic-deriving.new.3463/ghc-generic-deriving.changes
2020-10-23 15:13:57.470122960 +0200
@@ -1,0 +2,11 @@
+Tue Oct 6 08:55:51 UTC 2020 - [email protected]
+
+- Update generic-deriving to version 1.14.
+ # 1.14 [2020.09.30]
+ * Remove instances for `Data.Semigroup.Option`, which is deprecated as of
+ `base-4.15.0.0`.
+ * Allow building with `template-haskell-2.17.0.0` (GHC 9.0).
+ * Fix a bug in which `deriveAll1` would needlessly reject data types whose
last
+ type parameter appears as an oversaturated argument to a type family.
+
+-------------------------------------------------------------------
Old:
----
generic-deriving-1.13.1.tar.gz
New:
----
generic-deriving-1.14.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ ghc-generic-deriving.spec ++++++
--- /var/tmp/diff_new_pack.3QX7pJ/_old 2020-10-23 15:13:58.262123342 +0200
+++ /var/tmp/diff_new_pack.3QX7pJ/_new 2020-10-23 15:13:58.262123342 +0200
@@ -19,7 +19,7 @@
%global pkg_name generic-deriving
%bcond_with tests
Name: ghc-%{pkg_name}
-Version: 1.13.1
+Version: 1.14
Release: 0
Summary: Generic programming library for generalised deriving
License: BSD-3-Clause
@@ -45,6 +45,48 @@
<http://www.haskell.org/haskellwiki/GHC.Generics> for more information.
Template Haskell code is provided for supporting older GHCs.
+This library is organized as follows:
+
+* "Generics.Deriving.Base" defines the core functionality for GHC generics,
+including the 'Generic(1)' classes and representation data types. On modern
+versions of GHC, this simply re-exports "GHC.Generics" from 'base'. On older
+versions of GHC, this module backports parts of "GHC.Generics" that were not
+included at the time, including 'Generic(1)' instances.
+
+* "Generics.Deriving.TH" implements Template Haskell functionality for deriving
+instances of 'Generic(1)'.
+
+* Educational code: in order to provide examples of how to define and use
+"GHC.Generics"-based defaults, this library offers a number of modules which
+define examples of type classes along with default implementations for the
+classes' methods. Currently, the following modules are provided:
+"Generics.Deriving.Copoint", "Generics.Deriving.ConNames",
+"Generics.Deriving.Enum", "Generics.Deriving.Eq", "Generics.Deriving.Foldable",
+"Generics.Deriving.Functor", "Generics.Deriving.Monoid",
+"Generics.Deriving.Semigroup", "Generics.Deriving.Show",
+"Generics.Deriving.Traversable", and "Generics.Deriving.Uniplate".
+
+It is worth emphasizing that these modules are primarly intended for
+educational purposes. Many of the classes in these modules resemble other
+commonly used classes—for example, 'GShow' from "Generics.Deriving.Show"
+resembles 'Show' from 'base'—but in general, the classes that
+'generic-deriving' defines are not drop-in replacements. Moreover, the generic
+defaults that 'generic-deriving' provide often make simplifying assumptions
+that may violate expectations of how these classes might work elsewhere.
+For example, the generic default for 'GShow' does not behave exactly like
+'deriving Show' would.
+
+If you are seeking "GHC.Generics"-based defaults for type classes in 'base',
+consider using the '<http://hackage.haskell.org/package/generic-data
+generic-data>' library.
+
+* "Generics.Deriving.Default" provides newtypes that allow leveraging the
+generic defaults in this library using the 'DerivingVia' GHC language
+extension.
+
+* "Generics.Deriving" re-exports "Generics.Deriving.Base",
+"Generics.Deriving.Default", and a selection of educational modules.
+
%package devel
Summary: Haskell %{pkg_name} library development files
Requires: %{name} = %{version}-%{release}
++++++ generic-deriving-1.13.1.tar.gz -> generic-deriving-1.14.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/generic-deriving-1.13.1/CHANGELOG.md
new/generic-deriving-1.14/CHANGELOG.md
--- old/generic-deriving-1.13.1/CHANGELOG.md 2001-09-09 03:46:40.000000000
+0200
+++ new/generic-deriving-1.14/CHANGELOG.md 2001-09-09 03:46:40.000000000
+0200
@@ -1,3 +1,10 @@
+# 1.14 [2020.09.30]
+* Remove instances for `Data.Semigroup.Option`, which is deprecated as of
+ `base-4.15.0.0`.
+* Allow building with `template-haskell-2.17.0.0` (GHC 9.0).
+* Fix a bug in which `deriveAll1` would needlessly reject data types whose last
+ type parameter appears as an oversaturated argument to a type family.
+
# 1.13.1 [2019.11.26]
* Backport the `Generic(1)` instances for `Kleisli` introduced in `base-4.14`.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/generic-deriving-1.13.1/README.md
new/generic-deriving-1.14/README.md
--- old/generic-deriving-1.13.1/README.md 2001-09-09 03:46:40.000000000
+0200
+++ new/generic-deriving-1.14/README.md 2001-09-09 03:46:40.000000000 +0200
@@ -24,3 +24,63 @@
The current implementation integrates with the new GHC Generics. See
http://www.haskell.org/haskellwiki/GHC.Generics for more information.
Template Haskell code is provided for supporting older GHCs.
+
+This library is organized as follows:
+
+* `Generics.Deriving.Base` defines the core functionality for GHC generics,
+ including the `Generic(1)` classes and representation data types.
+ On modern versions of GHC, this simply re-exports `GHC.Generics` from
+ `base`. On older versions of GHC, this module backports parts of
+ `GHC.Generics` that were not included at the time, including `Generic(1)`
+ instances.
+
+* `Generics.Deriving.TH` implements Template Haskell functionality for
+ deriving instances of `Generic(1)`.
+
+* Educational code: in order to provide examples of how to define and use
+ `GHC.Generics`-based defaults, this library offers a number of modules
+ which define examples of type classes along with default implementations
+ for the classes' methods. Currently, the following modules are provided:
+
+ * `Generics.Deriving.Copoint`
+
+ * `Generics.Deriving.ConNames`
+
+ * `Generics.Deriving.Enum`
+
+ * `Generics.Deriving.Eq`
+
+ * `Generics.Deriving.Foldable`
+
+ * `Generics.Deriving.Functor`
+
+ * `Generics.Deriving.Monoid`
+
+ * `Generics.Deriving.Semigroup`
+
+ * `Generics.Deriving.Show`
+
+ * `Generics.Deriving.Traversable`
+
+ * `Generics.Deriving.Uniplate`
+
+ It is worth emphasizing that these modules are primarly intended for
+ educational purposes. Many of the classes in these modules resemble other
+ commonly used classes—for example, `GShow` from `Generics.Deriving.Show`
+ resembles `Show` from `base`—but in general, the classes that
+ `generic-deriving` defines are not drop-in replacements. Moreover, the
+ generic defaults that `generic-deriving` provide often make simplifying
+ assumptions that may violate expectations of how these classes might work
+ elsewhere. For example, the generic default for `GShow` does not behave
+ exactly like `deriving Show` would.
+
+ If you are seeking `GHC.Generics`-based defaults for type classes in
+ `base`, consider using the
+ [`generic-data`](http://hackage.haskell.org/package/generic-data) library.
+
+* `Generics.Deriving.Default` provides newtypes that allow leveraging the
+ generic defaults in this library using the `DerivingVia` GHC language
+ extension.
+
+* `Generics.Deriving` re-exports `Generics.Deriving.Base`,
+ `Generics.Deriving.Default`, and a selection of educational modules.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/generic-deriving-1.13.1/generic-deriving.cabal
new/generic-deriving-1.14/generic-deriving.cabal
--- old/generic-deriving-1.13.1/generic-deriving.cabal 2001-09-09
03:46:40.000000000 +0200
+++ new/generic-deriving-1.14/generic-deriving.cabal 2001-09-09
03:46:40.000000000 +0200
@@ -1,5 +1,5 @@
name: generic-deriving
-version: 1.13.1
+version: 1.14
synopsis: Generic programming library for generalised deriving.
description:
@@ -13,6 +13,50 @@
The current implementation integrates with the new GHC Generics. See
<http://www.haskell.org/haskellwiki/GHC.Generics> for more information.
Template Haskell code is provided for supporting older GHCs.
+ .
+ This library is organized as follows:
+ .
+ * "Generics.Deriving.Base" defines the core functionality for GHC generics,
+ including the @Generic(1)@ classes and representation data types.
+ On modern versions of GHC, this simply re-exports "GHC.Generics" from
+ @base@. On older versions of GHC, this module backports parts of
+ "GHC.Generics" that were not included at the time, including @Generic(1)@
+ instances.
+ .
+ * "Generics.Deriving.TH" implements Template Haskell functionality for
+ deriving instances of @Generic(1)@.
+ .
+ * Educational code: in order to provide examples of how to define and use
+ "GHC.Generics"-based defaults, this library offers a number of modules
+ which define examples of type classes along with default implementations
+ for the classes' methods. Currently, the following modules are provided:
+ "Generics.Deriving.Copoint", "Generics.Deriving.ConNames",
+ "Generics.Deriving.Enum", "Generics.Deriving.Eq",
+ "Generics.Deriving.Foldable", "Generics.Deriving.Functor",
+ "Generics.Deriving.Monoid", "Generics.Deriving.Semigroup",
+ "Generics.Deriving.Show", "Generics.Deriving.Traversable",
+ and "Generics.Deriving.Uniplate".
+ .
+ It is worth emphasizing that these modules are primarly intended for
+ educational purposes. Many of the classes in these modules resemble other
+ commonly used classes—for example, @GShow@ from "Generics.Deriving.Show"
+ resembles @Show@ from @base@—but in general, the classes that
+ @generic-deriving@ defines are not drop-in replacements. Moreover, the
+ generic defaults that @generic-deriving@ provide often make simplifying
+ assumptions that may violate expectations of how these classes might work
+ elsewhere. For example, the generic default for @GShow@ does not behave
+ exactly like @deriving Show@ would.
+ .
+ If you are seeking "GHC.Generics"-based defaults for type classes in
+ @base@, consider using the
+ @<http://hackage.haskell.org/package/generic-data generic-data>@ library.
+ .
+ * "Generics.Deriving.Default" provides newtypes that allow leveraging the
+ generic defaults in this library using the @DerivingVia@ GHC language
+ extension.
+ .
+ * "Generics.Deriving" re-exports "Generics.Deriving.Base",
+ "Generics.Deriving.Default", and a selection of educational modules.
homepage: https://github.com/dreixel/generic-deriving
bug-reports: https://github.com/dreixel/generic-deriving/issues
@@ -35,7 +79,7 @@
, GHC == 8.2.2
, GHC == 8.4.4
, GHC == 8.6.5
- , GHC == 8.8.1
+ , GHC == 8.8.3
, GHC == 8.10.1
extra-source-files: CHANGELOG.md
, README.md
@@ -83,8 +127,8 @@
build-depends: containers >= 0.1 && < 0.7
, ghc-prim < 1
- , template-haskell >= 2.4 && < 2.17
- , th-abstraction >= 0.3 && < 0.4
+ , template-haskell >= 2.4 && < 2.18
+ , th-abstraction >= 0.4 && < 0.5
default-language: Haskell2010
ghc-options: -Wall
@@ -95,12 +139,15 @@
other-modules: DefaultSpec
EmptyCaseSpec
ExampleSpec
+ T68Spec
TypeInTypeSpec
build-depends: base >= 4.3 && < 5
, generic-deriving
, hspec >= 2 && < 3
- , template-haskell >= 2.4 && < 2.17
+ , template-haskell >= 2.4 && < 2.18
build-tool-depends: hspec-discover:hspec-discover
hs-source-dirs: tests
default-language: Haskell2010
ghc-options: -Wall -threaded -rtsopts
+ if impl(ghc >= 8.6)
+ ghc-options: -Wno-star-is-type
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/generic-deriving-1.13.1/src/Generics/Deriving/Enum.hs
new/generic-deriving-1.14/src/Generics/Deriving/Enum.hs
--- old/generic-deriving-1.13.1/src/Generics/Deriving/Enum.hs 2001-09-09
03:46:40.000000000 +0200
+++ new/generic-deriving-1.14/src/Generics/Deriving/Enum.hs 2001-09-09
03:46:40.000000000 +0200
@@ -71,7 +71,7 @@
#if MIN_VERSION_base(4,9,0)
import Data.List.NonEmpty (NonEmpty)
import qualified Data.Semigroup as Semigroup (First, Last)
-import Data.Semigroup (Arg, Max, Min, Option, WrappedMonoid)
+import Data.Semigroup (Arg, Max, Min, WrappedMonoid)
#endif
-----------------------------------------------------------------------------
@@ -477,9 +477,6 @@
#if MIN_VERSION_base(4,9,0)
instance GEnum a => GEnum (NonEmpty a) where
genum = genumDefault
-
-instance GEnum a => GEnum (Option a) where
- genum = genumDefault
#endif
instance GEnum Ordering where
@@ -1019,13 +1016,6 @@
range = rangeDefault
index = indexDefault
inRange = inRangeDefault
-#endif
-
-#if MIN_VERSION_base(4,9,0)
-instance (GEq a, GEnum a, GIx a) => GIx (Option a) where
- range = rangeDefault
- index = indexDefault
- inRange = inRangeDefault
#endif
instance GIx Ordering where
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/generic-deriving-1.13.1/src/Generics/Deriving/Eq.hs
new/generic-deriving-1.14/src/Generics/Deriving/Eq.hs
--- old/generic-deriving-1.13.1/src/Generics/Deriving/Eq.hs 2001-09-09
03:46:40.000000000 +0200
+++ new/generic-deriving-1.14/src/Generics/Deriving/Eq.hs 2001-09-09
03:46:40.000000000 +0200
@@ -72,7 +72,7 @@
#if MIN_VERSION_base(4,9,0)
import Data.List.NonEmpty (NonEmpty)
import qualified Data.Semigroup as Semigroup (First, Last)
-import Data.Semigroup (Arg(..), Max, Min, Option, WrappedMonoid)
+import Data.Semigroup (Arg(..), Max, Min, WrappedMonoid)
#endif
--------------------------------------------------------------------------------
@@ -480,9 +480,6 @@
#if MIN_VERSION_base(4,9,0)
instance GEq a => GEq (NonEmpty a) where
geq = geqdefault
-
-instance GEq a => GEq (Option a) where
- geq = geqdefault
#endif
instance GEq Ordering where
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/generic-deriving-1.13.1/src/Generics/Deriving/Foldable.hs
new/generic-deriving-1.14/src/Generics/Deriving/Foldable.hs
--- old/generic-deriving-1.13.1/src/Generics/Deriving/Foldable.hs
2001-09-09 03:46:40.000000000 +0200
+++ new/generic-deriving-1.14/src/Generics/Deriving/Foldable.hs 2001-09-09
03:46:40.000000000 +0200
@@ -81,7 +81,7 @@
import qualified Data.Functor.Sum as Functor (Sum)
import Data.List.NonEmpty (NonEmpty)
import qualified Data.Semigroup as Semigroup (First, Last)
-import Data.Semigroup (Arg, Max, Min, Option, WrappedMonoid)
+import Data.Semigroup (Arg, Max, Min, WrappedMonoid)
#endif
--------------------------------------------------------------------------------
@@ -242,9 +242,6 @@
instance GFoldable NonEmpty where
gfoldMap = gfoldMapdefault
-
-instance GFoldable Option where
- gfoldMap = gfoldMapdefault
#endif
instance GFoldable Monoid.Product where
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/generic-deriving-1.13.1/src/Generics/Deriving/Functor.hs
new/generic-deriving-1.14/src/Generics/Deriving/Functor.hs
--- old/generic-deriving-1.13.1/src/Generics/Deriving/Functor.hs
2001-09-09 03:46:40.000000000 +0200
+++ new/generic-deriving-1.14/src/Generics/Deriving/Functor.hs 2001-09-09
03:46:40.000000000 +0200
@@ -66,7 +66,7 @@
import qualified Data.Functor.Sum as Functor (Sum)
import Data.List.NonEmpty (NonEmpty)
import qualified Data.Semigroup as Semigroup (First, Last)
-import Data.Semigroup (Arg, Max, Min, Option, WrappedMonoid)
+import Data.Semigroup (Arg, Max, Min, WrappedMonoid)
#endif
--------------------------------------------------------------------------------
@@ -212,9 +212,6 @@
instance GFunctor NonEmpty where
gmap = gmapdefault
-
-instance GFunctor Option where
- gmap = gmapdefault
#endif
instance GFunctor Monoid.Product where
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/generic-deriving-1.13.1/src/Generics/Deriving/Semigroup/Internal.hs
new/generic-deriving-1.14/src/Generics/Deriving/Semigroup/Internal.hs
--- old/generic-deriving-1.13.1/src/Generics/Deriving/Semigroup/Internal.hs
2001-09-09 03:46:40.000000000 +0200
+++ new/generic-deriving-1.14/src/Generics/Deriving/Semigroup/Internal.hs
2001-09-09 03:46:40.000000000 +0200
@@ -189,9 +189,6 @@
instance GSemigroup (NonEmpty a) where
gsappend = (<>)
-
-instance GSemigroup a => GSemigroup (Option a) where
- gsappend (Option a) (Option b) = Option (gsappend a b)
#endif
-- Tuple instances
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/generic-deriving-1.13.1/src/Generics/Deriving/Show.hs
new/generic-deriving-1.14/src/Generics/Deriving/Show.hs
--- old/generic-deriving-1.13.1/src/Generics/Deriving/Show.hs 2001-09-09
03:46:40.000000000 +0200
+++ new/generic-deriving-1.14/src/Generics/Deriving/Show.hs 2001-09-09
03:46:40.000000000 +0200
@@ -68,7 +68,7 @@
#if MIN_VERSION_base(4,9,0)
import Data.List.NonEmpty (NonEmpty)
import qualified Data.Semigroup as Semigroup (First, Last)
-import Data.Semigroup (Arg, Max, Min, Option, WrappedMonoid)
+import Data.Semigroup (Arg, Max, Min, WrappedMonoid)
#endif
--------------------------------------------------------------------------------
@@ -540,9 +540,6 @@
#if MIN_VERSION_base(4,9,0)
instance GShow a => GShow (NonEmpty a) where
gshowsPrec = gshowsPrecdefault
-
-instance GShow a => GShow (Option a) where
- gshowsPrec = gshowsPrecdefault
#endif
instance GShow Ordering where
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/generic-deriving-1.13.1/src/Generics/Deriving/TH/Internal.hs
new/generic-deriving-1.14/src/Generics/Deriving/TH/Internal.hs
--- old/generic-deriving-1.13.1/src/Generics/Deriving/TH/Internal.hs
2001-09-09 03:46:40.000000000 +0200
+++ new/generic-deriving-1.14/src/Generics/Deriving/TH/Internal.hs
2001-09-09 03:46:40.000000000 +0200
@@ -26,6 +26,7 @@
import Data.Set (Set)
import Language.Haskell.TH.Datatype
+import Language.Haskell.TH.Datatype.TyVarBndr
import Language.Haskell.TH.Lib
import Language.Haskell.TH.Ppr (pprint)
import Language.Haskell.TH.Syntax
@@ -101,9 +102,9 @@
-- | Converts a VarT or a SigT into Just the corresponding TyVarBndr.
-- Converts other Types to Nothing.
-typeToTyVarBndr :: Type -> Maybe TyVarBndr
-typeToTyVarBndr (VarT n) = Just (PlainTV n)
-typeToTyVarBndr (SigT (VarT n) k) = Just (KindedTV n k)
+typeToTyVarBndr :: Type -> Maybe TyVarBndrUnit
+typeToTyVarBndr (VarT n) = Just (plainTV n)
+typeToTyVarBndr (SigT (VarT n) k) = Just (kindedTV n k)
typeToTyVarBndr _ = Nothing
-- | If a Type is a SigT, returns its kind signature. Otherwise, return *.
@@ -143,38 +144,63 @@
makeFunKind argKinds resKind = foldr' ArrowK resKind argKinds
#endif
--- | Is the given type a type family constructor (and not a data family
constructor)?
-isTyFamily :: Type -> Q Bool
-isTyFamily (ConT n) = do
- info <- reify n
- return $ case info of
+-- | Detect if a Name occurs as an argument to some type family. This makes an
+-- effort to exclude /oversaturated/ arguments to type families. For instance,
+-- if one declared the following type family:
+--
+-- @
+-- type family F a :: Type -> Type
+-- @
+--
+-- Then in the type @F a b@, we would consider @a@ to be an argument to @F@,
+-- but not @b@.
+isInTypeFamilyApp :: Name -> Type -> [Type] -> Q Bool
+isInTypeFamilyApp name tyFun tyArgs =
+ case tyFun of
+ ConT tcName -> go tcName
+ _ -> return False
+ where
+ go :: Name -> Q Bool
+ go tcName = do
+ info <- reify tcName
+ case info of
#if MIN_VERSION_template_haskell(2,11,0)
- FamilyI OpenTypeFamilyD{} _ -> True
+ FamilyI (OpenTypeFamilyD (TypeFamilyHead _ bndrs _ _)) _
+ -> withinFirstArgs bndrs
#elif MIN_VERSION_template_haskell(2,7,0)
- FamilyI (FamilyD TypeFam _ _ _) _ -> True
+ FamilyI (FamilyD TypeFam _ bndrs _) _
+ -> withinFirstArgs bndrs
#else
- TyConI (FamilyD TypeFam _ _ _) -> True
+ TyConI (FamilyD TypeFam _ bndrs _)
+ -> withinFirstArgs bndrs
#endif
-#if MIN_VERSION_template_haskell(2,9,0)
- FamilyI ClosedTypeFamilyD{} _ -> True
+
+#if MIN_VERSION_template_haskell(2,11,0)
+ FamilyI (ClosedTypeFamilyD (TypeFamilyHead _ bndrs _ _) _) _
+ -> withinFirstArgs bndrs
+#elif MIN_VERSION_template_haskell(2,9,0)
+ FamilyI (ClosedTypeFamilyD _ bndrs _ _) _
+ -> withinFirstArgs bndrs
#endif
- _ -> False
-isTyFamily _ = return False
+
+ _ -> return False
+ where
+ withinFirstArgs :: [a] -> Q Bool
+ withinFirstArgs bndrs =
+ let firstArgs = take (length bndrs) tyArgs
+ argFVs = freeVariables firstArgs
+ in return $ name `elem` argFVs
-- | True if the type does not mention the Name
ground :: Type -> Name -> Bool
-ground (AppT t1 t2) name = ground t1 name && ground t2 name
-ground (SigT t _) name = ground t name
-ground (VarT t) name = t /= name
-ground ForallT{} _ = rankNError
-ground _ _ = True
+ground ty name = name `notElem` freeVariables ty
-- | Construct a type via curried application.
applyTyToTys :: Type -> [Type] -> Type
applyTyToTys = foldl' AppT
-- | Apply a type constructor name to type variable binders.
-applyTyToTvbs :: Name -> [TyVarBndr] -> Type
+applyTyToTvbs :: Name -> [TyVarBndr_ flag] -> Type
applyTyToTvbs = foldl' (\a -> AppT a . tyVarBndrToType) . ConT
-- | Split an applied type into its individual components. For example, this:
@@ -188,14 +214,17 @@
-- @
-- [Either, Int, Char]
-- @
-unapplyTy :: Type -> [Type]
-unapplyTy = reverse . go
+unapplyTy :: Type -> (Type, [Type])
+unapplyTy ty = go ty ty []
where
- go :: Type -> [Type]
- go (AppT t1 t2) = t2 : go t1
- go (SigT t _) = go t
- go (ForallT _ _ t) = go t
- go t = [t]
+ go :: Type -> Type -> [Type] -> (Type, [Type])
+ go _ (AppT ty1 ty2) args = go ty1 ty1 (ty2:args)
+ go origTy (SigT ty' _) args = go origTy ty' args
+#if MIN_VERSION_template_haskell(2,11,0)
+ go origTy (InfixT ty1 n ty2) args = go origTy (ConT n `AppT` ty1 `AppT`
ty2) args
+ go origTy (ParensT ty') args = go origTy ty' args
+#endif
+ go origTy _ args = (origTy, args)
-- | Split a type signature by the arrows on its spine. For example, this:
--
@@ -208,7 +237,7 @@
-- @
-- ([a, b], [a -> b, Char, ()])
-- @
-uncurryTy :: Type -> ([TyVarBndr], [Type])
+uncurryTy :: Type -> ([TyVarBndrSpec], [Type])
uncurryTy (AppT (AppT ArrowT t1) t2) =
let (tvbs, tys) = uncurryTy t2
in (tvbs, t1:tys)
@@ -219,7 +248,7 @@
uncurryTy t = ([], [t])
-- | Like uncurryType, except on a kind level.
-uncurryKind :: Kind -> ([TyVarBndr], [Kind])
+uncurryKind :: Kind -> ([TyVarBndrSpec], [Kind])
#if MIN_VERSION_template_haskell(2,8,0)
uncurryKind = uncurryTy
#else
@@ -229,9 +258,8 @@
uncurryKind k = ([], [k])
#endif
-tyVarBndrToType :: TyVarBndr -> Type
-tyVarBndrToType (PlainTV n) = VarT n
-tyVarBndrToType (KindedTV n k) = SigT (VarT n) k
+tyVarBndrToType :: TyVarBndr_ flag -> Type
+tyVarBndrToType = elimTV VarT (\n k -> SigT (VarT n) k)
-- | Generate a list of fresh names with a common prefix, and numbered
suffixes.
newNameList :: String -> Int -> Q [Name]
@@ -294,9 +322,8 @@
unSigT t = t
-- | Peel off a kind signature from a TyVarBndr (if it has one).
-unKindedTV :: TyVarBndr -> TyVarBndr
-unKindedTV (KindedTV n _) = PlainTV n
-unKindedTV tvb = tvb
+unKindedTV :: TyVarBndrUnit -> TyVarBndrUnit
+unKindedTV tvb = elimTV (\_ -> tvb) (\n _ -> plainTV n) tvb
-- | Does the given type mention any of the Names in the list?
mentionsName :: Type -> [Name] -> Bool
@@ -361,7 +388,7 @@
-- Determines the universally quantified type variables (possibly after
-- substituting * in the case of Generic1) and the last type parameter name
-- (if there is one).
-genericKind :: GenericClass -> [Type] -> ([TyVarBndr], GenericKind)
+genericKind :: GenericClass -> [Type] -> ([TyVarBndrUnit], GenericKind)
genericKind gClass tySynVars =
case gClass of
Generic -> (freeVariablesWellScoped tySynVars, Gen0)
@@ -437,9 +464,13 @@
. showString "‘\n\tClass Generic1 expects an argument of kind * -> *"
$ ""
+-- | The data type mentions the last type variable in a place other
+-- than the last position of a data type in a constructor's field.
outOfPlaceTyVarError :: Q a
outOfPlaceTyVarError = fail
- "Type applied to an argument involving the last parameter is not of kind *
-> *"
+ . showString "Constructor must only use its last type variable as"
+ . showString " the last argument of a data type"
+ $ ""
-- | Cannot have a constructor argument of form (forall a1 ... an. <type>)
-- when deriving Generic(1)
@@ -486,7 +517,7 @@
nameBase dataName ++ " must not have a datatype context"
-- | Deriving Generic(1) doesn't work with ExistentialQuantification or GADTs.
-checkExistentialContext :: Name -> [TyVarBndr] -> Cxt -> Q ()
+checkExistentialContext :: Name -> [TyVarBndrUnit] -> Cxt -> Q ()
checkExistentialContext conName vars ctxt =
unless (null vars && null ctxt) $ fail $
nameBase conName ++ " must be a vanilla data constructor"
@@ -821,9 +852,6 @@
undefinedValName :: Name
undefinedValName = mkNameG_v "base" "GHC.Err" "undefined"
-starKindName :: Name
-starKindName = mkGHCPrimName_tc "GHC.Prim" "*"
-
decidedLazyDataName :: Name
decidedLazyDataName = mkGD4'9_d "DecidedLazy"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/generic-deriving-1.13.1/src/Generics/Deriving/TH.hs
new/generic-deriving-1.14/src/Generics/Deriving/TH.hs
--- old/generic-deriving-1.13.1/src/Generics/Deriving/TH.hs 2001-09-09
03:46:40.000000000 +0200
+++ new/generic-deriving-1.14/src/Generics/Deriving/TH.hs 2001-09-09
03:46:40.000000000 +0200
@@ -345,11 +345,7 @@
let origSigTy = if useKindSigs
then SigT origTy origKind
else origTy
- tyIns <- tySynInstDCompat repName
-#if MIN_VERSION_th_abstraction(0,3,0)
- Nothing
-#endif
- [return origSigTy] (return tyInsRHS)
+ tyIns <- tySynInstDCompat repName Nothing [return origSigTy] (return
tyInsRHS)
let ecOptions = emptyCaseOptions opts
mkBody maker = [clause [] (normalB $
mkCaseExp gClass ecOptions name instTys cons maker) []]
@@ -754,7 +750,7 @@
repFieldArg Gen0 t = boxT t
repFieldArg (Gen1 name _) (VarT t) | t == name = conT par1TypeName
repFieldArg gk@(Gen1 name _) t = do
- let tyHead:tyArgs = unapplyTy t
+ let (tyHead, tyArgs) = unapplyTy t
numLastArgs = min 1 $ length tyArgs
(lhsArgs, rhsArgs) = splitAt (length tyArgs - numLastArgs) tyArgs
rec0Type = boxT t
@@ -771,9 +767,8 @@
`appT` repFieldArg gk beta
inspectTy _ = rec0Type
- itf <- isTyFamily tyHead
- if any (not . (`ground` name)) lhsArgs
- || any (not . (`ground` name)) tyArgs && itf
+ itf <- isInTypeFamilyApp name tyHead tyArgs
+ if any (not . (`ground` name)) lhsArgs || itf
then outOfPlaceTyVarError
else case rhsArgs of
[] -> rec0Type
@@ -888,7 +883,7 @@
wC t name
| ground t name = conE $ boxRepName t
| otherwise = do
- let tyHead:tyArgs = unapplyTy t
+ let (tyHead, tyArgs) = unapplyTy t
numLastArgs = min 1 $ length tyArgs
(lhsArgs, rhsArgs) = splitAt (length tyArgs - numLastArgs) tyArgs
@@ -902,9 +897,8 @@
(varE composeValName)
(varE fmapValName `appE` wC beta name)
- itf <- isTyFamily tyHead
- if any (not . (`ground` name)) lhsArgs
- || any (not . (`ground` name)) tyArgs && itf
+ itf <- isInTypeFamilyApp name tyHead tyArgs
+ if any (not . (`ground` name)) lhsArgs || itf
then outOfPlaceTyVarError
else case rhsArgs of
[] -> conE $ boxRepName t
@@ -947,7 +941,7 @@
unwC t name
| ground t name = varE $ unboxRepName t
| otherwise = do
- let tyHead:tyArgs = unapplyTy t
+ let (tyHead, tyArgs) = unapplyTy t
numLastArgs = min 1 $ length tyArgs
(lhsArgs, rhsArgs) = splitAt (length tyArgs - numLastArgs) tyArgs
@@ -961,9 +955,8 @@
(varE composeValName)
(varE unComp1ValName)
- itf <- isTyFamily tyHead
- if any (not . (`ground` name)) lhsArgs
- || any (not . (`ground` name)) tyArgs && itf
+ itf <- isInTypeFamilyApp name tyHead tyArgs
+ if any (not . (`ground` name)) lhsArgs || itf
then outOfPlaceTyVarError
else case rhsArgs of
[] -> varE $ unboxRepName t
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/generic-deriving-1.13.1/src/Generics/Deriving/Traversable.hs
new/generic-deriving-1.14/src/Generics/Deriving/Traversable.hs
--- old/generic-deriving-1.13.1/src/Generics/Deriving/Traversable.hs
2001-09-09 03:46:40.000000000 +0200
+++ new/generic-deriving-1.14/src/Generics/Deriving/Traversable.hs
2001-09-09 03:46:40.000000000 +0200
@@ -70,7 +70,7 @@
import qualified Data.Functor.Sum as Functor (Sum)
import Data.List.NonEmpty (NonEmpty)
import qualified Data.Semigroup as Semigroup (First, Last)
-import Data.Semigroup (Arg, Max, Min, Option, WrappedMonoid)
+import Data.Semigroup (Arg, Max, Min, WrappedMonoid)
#endif
--------------------------------------------------------------------------------
@@ -214,9 +214,6 @@
instance GTraversable NonEmpty where
gtraverse = gtraversedefault
-
-instance GTraversable Option where
- gtraverse = gtraversedefault
#endif
instance GTraversable Monoid.Product where
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/generic-deriving-1.13.1/tests/DefaultSpec.hs
new/generic-deriving-1.14/tests/DefaultSpec.hs
--- old/generic-deriving-1.13.1/tests/DefaultSpec.hs 2001-09-09
03:46:40.000000000 +0200
+++ new/generic-deriving-1.14/tests/DefaultSpec.hs 2001-09-09
03:46:40.000000000 +0200
@@ -28,7 +28,7 @@
#if __GLASGOW_HASKELL__ >= 806
import Test.Hspec.QuickCheck
-import Data.Semigroup (First(..), Option(..))
+import Data.Semigroup (First(..))
import Data.Foldable (sequenceA_)
import Generics.Deriving hiding (universe)
import Generics.Deriving.Default ()
@@ -132,7 +132,7 @@
deriving (GSemigroup) via (First Bool)
newtype TestFoldable a = TestFoldable (Maybe a)
- deriving (GFoldable) via (Default1 Option)
+ deriving (GFoldable) via (Default1 Maybe)
newtype TestFunctor a = TestFunctor (Maybe a)
deriving stock (Eq, Show, Functor)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/generic-deriving-1.13.1/tests/T68Spec.hs
new/generic-deriving-1.14/tests/T68Spec.hs
--- old/generic-deriving-1.13.1/tests/T68Spec.hs 1970-01-01
01:00:00.000000000 +0100
+++ new/generic-deriving-1.14/tests/T68Spec.hs 2001-09-09 03:46:40.000000000
+0200
@@ -0,0 +1,23 @@
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE TemplateHaskell #-}
+{-# LANGUAGE TypeFamilies #-}
+
+#if __GLASGOW_HASKELL__ >= 706
+{-# LANGUAGE DataKinds #-}
+#endif
+
+module T68Spec (main, spec) where
+
+import Generics.Deriving.TH
+import Test.Hspec
+
+main :: IO ()
+main = hspec spec
+
+spec :: Spec
+spec = return ()
+
+type family F68 :: * -> *
+type instance F68 = Maybe
+data T68 a = MkT68 (F68 a)
+$(deriveAll1 ''T68)