Hello community,

here is the log from the commit of package ghc-th-abstraction for 
openSUSE:Factory checked in at 2018-05-30 12:14:29
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-th-abstraction (Old)
 and      /work/SRC/openSUSE:Factory/.ghc-th-abstraction.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "ghc-th-abstraction"

Wed May 30 12:14:29 2018 rev:2 rq:607901 version:0.2.6.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc-th-abstraction/ghc-th-abstraction.changes    
2017-08-31 21:03:23.109065906 +0200
+++ 
/work/SRC/openSUSE:Factory/.ghc-th-abstraction.new/ghc-th-abstraction.changes   
    2018-05-30 12:27:31.997804721 +0200
@@ -1,0 +2,24 @@
+Mon May 14 17:02:11 UTC 2018 - [email protected]
+
+- Update th-abstraction to version 0.2.6.0 revision 1.
+  * Fix bug in which `applySubstitution` and `freeVariables` would ignore
+    type variables in the kinds of type variable binders.
+  * Added `pragLineDCompat`, `newtypeDCompat` and `tySynInstDCompat`
+  * Fix bug that caused GADT equality constraints to be incorrect in some 
cases.
+  * Expose `Unpackedness` and `Strictness` (which were unexported by accident).
+  * Add `resolvePredSynonyms`
+  * Add `reifyConstructor`, which allows reification of `ConstructorInfo` from
+    a constructor name, and `lookupByConstructorName`, which allows directly
+    looking up a `ConstructorInfo` from a `DatatypeInfo` value for a given
+    constructor `Name`.
+  * Augment `reifyDatatype` to be able to look up `DatatypeInfo` from the 
`Name`
+    of a record selector for one of its constructors. Also add `reifyRecord` 
for
+    reification of of `ConstructorInfo` from a record name, and
+    `lookupByRecordName`, which allows directly looking up a `ConstructorInfo`
+    from a `DatatypeInfo` value for a given record `Name`.
+  * Fix bug that caused `th-abstraction` to fail on GHC 7.0 and 7.2 when 
passing
+    a vanilla constructor name to `reifyDatatype`
+  * Make `normalizeDec` and `normalizeCon` more robust with respect to
+    data family instances on GHC 7.6 and 7.8
+
+-------------------------------------------------------------------

Old:
----
  th-abstraction-0.2.3.0.tar.gz

New:
----
  th-abstraction-0.2.6.0.tar.gz
  th-abstraction.cabal

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ ghc-th-abstraction.spec ++++++
--- /var/tmp/diff_new_pack.EL9KSv/_old  2018-05-30 12:27:32.853774844 +0200
+++ /var/tmp/diff_new_pack.EL9KSv/_new  2018-05-30 12:27:32.857774704 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package ghc-th-abstraction
 #
-# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -19,18 +19,18 @@
 %global pkg_name th-abstraction
 %bcond_with tests
 Name:           ghc-%{pkg_name}
-Version:        0.2.3.0
+Version:        0.2.6.0
 Release:        0
 Summary:        Nicer interface for reified information about data types
 License:        ISC
-Group:          Development/Languages/Other
-Url:            https://hackage.haskell.org/package/%{pkg_name}
+Group:          Development/Libraries/Haskell
+URL:            https://hackage.haskell.org/package/%{pkg_name}
 Source0:        
https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz
+Source1:        
https://hackage.haskell.org/package/%{pkg_name}-%{version}/revision/1.cabal#/%{pkg_name}.cabal
 BuildRequires:  ghc-Cabal-devel
 BuildRequires:  ghc-containers-devel
 BuildRequires:  ghc-rpm-macros
 BuildRequires:  ghc-template-haskell-devel
-BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 
 %description
 This package normalizes variations in the interface for inspecting datatype
@@ -40,7 +40,7 @@
 
 %package devel
 Summary:        Haskell %{pkg_name} library development files
-Group:          Development/Libraries/Other
+Group:          Development/Libraries/Haskell
 Requires:       %{name} = %{version}-%{release}
 Requires:       ghc-compiler = %{ghc_version}
 Requires(post): ghc-compiler = %{ghc_version}
@@ -51,6 +51,7 @@
 
 %prep
 %setup -q -n %{pkg_name}-%{version}
+cp -p %{SOURCE1} %{pkg_name}.cabal
 
 %build
 %ghc_lib_build
@@ -68,11 +69,9 @@
 %ghc_pkg_recache
 
 %files -f %{name}.files
-%defattr(-,root,root,-)
-%doc LICENSE
+%license LICENSE
 
 %files devel -f %{name}-devel.files
-%defattr(-,root,root,-)
 %doc ChangeLog.md README.md
 
 %changelog

++++++ th-abstraction-0.2.3.0.tar.gz -> th-abstraction-0.2.6.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/th-abstraction-0.2.3.0/ChangeLog.md 
new/th-abstraction-0.2.6.0/ChangeLog.md
--- old/th-abstraction-0.2.3.0/ChangeLog.md     2017-06-26 23:04:22.000000000 
+0200
+++ new/th-abstraction-0.2.6.0/ChangeLog.md     2017-09-05 04:55:33.000000000 
+0200
@@ -1,5 +1,18 @@
 # Revision history for th-abstraction
 
+## 0.2.6.0 -- 2017-09-04
+* Fix bug in which `applySubstitution` and `freeVariables` would ignore
+  type variables in the kinds of type variable binders.
+
+## 0.2.5.0
+
+* Added `pragLineDCompat`, `newtypeDCompat` and `tySynInstDCompat`
+
+## 0.2.4.0 -- 2017-07-31
+
+* Fix bug that caused GADT equality constraints to be incorrect in some cases.
+* Expose `Unpackedness` and `Strictness` (which were unexported by accident).
+
 ## 0.2.3.0 -- 2017-06-26
 
 * Add `resolvePredSynonyms`
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/th-abstraction-0.2.3.0/src/Language/Haskell/TH/Datatype.hs 
new/th-abstraction-0.2.6.0/src/Language/Haskell/TH/Datatype.hs
--- old/th-abstraction-0.2.3.0/src/Language/Haskell/TH/Datatype.hs      
2017-06-26 23:04:22.000000000 +0200
+++ new/th-abstraction-0.2.6.0/src/Language/Haskell/TH/Datatype.hs      
2017-09-05 04:55:33.000000000 +0200
@@ -60,6 +60,8 @@
   , DatatypeVariant(..)
   , ConstructorVariant(..)
   , FieldStrictness(..)
+  , Unpackedness(..)
+  , Strictness(..)
 
   -- * Normalization functions
   , reifyDatatype
@@ -86,6 +88,9 @@
 
   -- * Backward compatible data definitions
   , dataDCompat
+  , newtypeDCompat
+  , tySynInstDCompat
+  , pragLineDCompat
   , arrowKCompat
 
   -- * Strictness annotations
@@ -106,6 +111,7 @@
   -- * Convenience functions
   , unifyTypes
   , tvName
+  , tvKind
   , datatypeType
   ) where
 
@@ -539,7 +545,7 @@
 
 -- If a VarT is missing an explicit kind signature, steal it from a TyVarBndr.
 stealKindForType :: TyVarBndr -> Type -> Type
-stealKindForType tvb t@VarT{} = SigT t (tvbKind tvb)
+stealKindForType tvb t@VarT{} = SigT t (tvKind tvb)
 stealKindForType _   t        = t
 
 -- | Normalize 'Dec' for a newtype or datatype into a 'DatatypeInfo'.
@@ -611,9 +617,9 @@
     PlainTV  t   -> VarT t
 
 -- | Extract the kind from a 'TyVarBndr'. Assumes 'PlainTV' has kind @*@.
-tvbKind :: TyVarBndr -> Kind
-tvbKind (PlainTV  _)   = starK
-tvbKind (KindedTV _ k) = k
+tvKind :: TyVarBndr -> Kind
+tvKind (PlainTV  _)   = starK
+tvKind (KindedTV _ k) = k
 
 -- | Remove the outermost 'SigT'.
 stripSigT :: Type -> Type
@@ -806,17 +812,18 @@
           mightHaveBeenEtaReduced ts =
             case unsnoc ts of
               Nothing -> False
-              Just (initTs,lastT) ->
+              Just (initTs :|- lastT) ->
                 case varTName lastT of
                   Nothing -> False
                   Just n  -> not (n `elem` freeVariables initTs)
 
-          -- If the list is empty returns 'Nothing', otherwise returns the 
'init' and the 'last'.
-          unsnoc :: [a] -> Maybe ([a], a)
+          -- If the list is empty returns 'Nothing', otherwise returns the
+          -- 'init' and the 'last'.
+          unsnoc :: [a] -> Maybe (NonEmptySnoc a)
           unsnoc [] = Nothing
-          unsnoc [x] = Just ([], x)
-          unsnoc (x:xs) = Just (x:a, b)
-              where Just (a,b) = unsnoc xs
+          unsnoc (x:xs) = case unsnoc xs of
+            Just (a :|- b) -> Just ((x:a) :|- b)
+            Nothing        -> Just ([]    :|- x)
 
           -- If a Type is a VarT, find Just its Name. Otherwise, return 
Nothing.
           varTName :: Type -> Maybe Name
@@ -878,16 +885,36 @@
   Q [ConstructorInfo]
 normalizeGadtC typename params tyvars context names innerType
                fields stricts getVariant =
-  do innerType' <- resolveTypeSynonyms innerType
+  do -- Due to GHC Trac #13885, it's possible that the type variables bound by
+     -- a GADT constructor will shadow those that are bound by the data type.
+     -- This function assumes this isn't the case in certain parts (e.g., when
+     -- mergeArguments is invoked), so we do an alpha-renaming of the
+     -- constructor-bound variables before proceeding. See #36 for an example
+     -- of what can go wrong if this isn't done.
+     let conBoundNames =
+           concatMap (\tvb -> tvName tvb:freeVariables (tvKind tvb)) tyvars
+     conSubst <- T.sequence $ Map.fromList [ (n, newName (nameBase n))
+                                           | n <- conBoundNames ]
+     let conSubst'     = fmap VarT conSubst
+         renamedTyvars =
+           map (\tvb -> case tvb of
+                          PlainTV n    -> PlainTV  (conSubst Map.! n)
+                          KindedTV n k -> KindedTV (conSubst Map.! n)
+                                                   (applySubstitution 
conSubst' k)) tyvars
+         renamedContext   = applySubstitution conSubst' context
+         renamedInnerType = applySubstitution conSubst' innerType
+         renamedFields    = applySubstitution conSubst' fields
+
+     innerType' <- resolveTypeSynonyms renamedInnerType
      case decomposeType innerType' of
        ConT innerTyCon :| ts | typename == innerTyCon ->
 
          let (substName, context1) = mergeArguments params ts
              subst   = VarT <$> substName
-             tyvars' = [ tv | tv <- tyvars, Map.notMember (tvName tv) subst ]
+             tyvars' = [ tv | tv <- renamedTyvars, Map.notMember (tvName tv) 
subst ]
 
-             context2 = applySubstitution subst (context1 ++ context)
-             fields'  = applySubstitution subst fields
+             context2 = applySubstitution subst (context1 ++ renamedContext)
+             fields'  = applySubstitution subst renamedFields
          in sequence [ ConstructorInfo name tyvars' context2
                                        fields' stricts <$> variantQ
                      | name <- names
@@ -1156,9 +1183,14 @@
   applySubstitution subst = go
     where
       go (ForallT tvs context t) =
-        let subst' = foldl' (flip Map.delete) subst (map tvName tvs) in
-        ForallT tvs (applySubstitution subst' context)
-                    (applySubstitution subst' t)
+        let subst' = foldl' (flip Map.delete) subst (map tvName tvs)
+
+            mapTvbKind :: (Kind -> Kind) -> TyVarBndr -> TyVarBndr
+            mapTvbKind f (PlainTV n)    = PlainTV n
+            mapTvbKind f (KindedTV n k) = KindedTV n (f k) in
+        ForallT (map (mapTvbKind (applySubstitution subst')) tvs)
+                (applySubstitution subst' context)
+                (applySubstitution subst' t)
       go (AppT f x)      = AppT (go f) (go x)
       go (SigT t k)      = SigT (go t) (applySubstitution subst k) -- k could 
be Kind
       go (VarT v)        = Map.findWithDefault (VarT v) v subst
@@ -1172,7 +1204,9 @@
   freeVariables t =
     case t of
       ForallT tvs context t' ->
-          (freeVariables context `union` freeVariables t')
+          (concatMap (freeVariables . tvKind) tvs
+              `union` freeVariables context
+              `union` freeVariables t')
           \\ map tvName tvs
       AppT f x      -> freeVariables f `union` freeVariables x
       SigT t' k     -> freeVariables t' `union` freeVariables k
@@ -1397,6 +1431,50 @@
 dataDCompat = dataD
 #endif
 
+-- | Backward compatible version of 'newtypeD'
+newtypeDCompat ::
+  CxtQ        {- ^ context                 -} ->
+  Name        {- ^ type constructor        -} ->
+  [TyVarBndr] {- ^ type parameters         -} ->
+  ConQ        {- ^ constructor definition  -} ->
+  [Name]      {- ^ derived class names     -} ->
+  DecQ
+#if MIN_VERSION_template_haskell(2,12,0)
+newtypeDCompat c n ts cs ds =
+  newtypeD c n ts Nothing cs
+    (if null ds then [] else [derivClause Nothing (map conT ds)])
+#elif MIN_VERSION_template_haskell(2,11,0)
+newtypeDCompat c n ts cs ds =
+  newtypeD c n ts Nothing cs
+    (return (map ConT ds))
+#else
+newtypeDCompat = newtypeD
+#endif
+
+-- | Backward compatible version of 'tySynInstD'
+tySynInstDCompat ::
+  Name    {- ^ type family name    -} ->
+  [TypeQ] {- ^ instance parameters -} ->
+  TypeQ   {- ^ instance result     -} ->
+  DecQ
+#if MIN_VERSION_template_haskell(2,9,0)
+tySynInstDCompat n ps r = TySynInstD n <$> (TySynEqn <$> sequence ps <*> r)
+#else
+tySynInstDCompat = tySynInstD
+#endif
+
+-- | Backward compatible version of 'pragLineD'. Returns
+-- 'Nothing' if line pragmas are not suported.
+pragLineDCompat ::
+  Int     {- ^ line number -} ->
+  String  {- ^ file name   -} ->
+  Maybe DecQ
+#if MIN_VERSION_template_haskell(2,10,0)
+pragLineDCompat ln fn = Just (pragLineD ln fn)
+#else
+pragLineDCompat _  _  = Nothing
+#endif
+
 arrowKCompat :: Kind -> Kind -> Kind
 #if MIN_VERSION_template_haskell(2,8,0)
 arrowKCompat x y = arrowK `appK` x `appK` y
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/th-abstraction-0.2.3.0/test/Main.hs 
new/th-abstraction-0.2.6.0/test/Main.hs
--- old/th-abstraction-0.2.3.0/test/Main.hs     2017-06-26 23:04:22.000000000 
+0200
+++ new/th-abstraction-0.2.6.0/test/Main.hs     2017-09-05 04:55:33.000000000 
+0200
@@ -23,15 +23,24 @@
 module Main (main) where
 
 #if __GLASGOW_HASKELL__ >= 704
-import Control.Monad (zipWithM_)
+import           Control.Monad (zipWithM_)
 #endif
 
-import Language.Haskell.TH
-import Language.Haskell.TH.Datatype
-import Language.Haskell.TH.Lib (starK)
+#if MIN_VERSION_template_haskell(2,8,0)
+import           Control.Monad (unless)
+import qualified Data.Map as Map
+#endif
+
+#if MIN_VERSION_base(4,7,0)
+import           Data.Type.Equality ((:~:)(..))
+#endif
 
-import Harness
-import Types
+import           Language.Haskell.TH
+import           Language.Haskell.TH.Datatype
+import           Language.Haskell.TH.Lib (starK)
+
+import           Harness
+import           Types
 
 -- | Test entry point. Tests will pass or fail at compile time.
 main :: IO ()
@@ -62,6 +71,12 @@
 #endif
      reifyDatatypeWithConNameTest
      reifyConstructorTest
+#if MIN_VERSION_base(4,7,0)
+     importedEqualityTest
+#endif
+#if MIN_VERSION_template_haskell(2,8,0)
+     kindSubstTest
+#endif
 
 adt1Test :: IO ()
 adt1Test =
@@ -521,7 +536,6 @@
 reifyDatatypeWithConNameTest :: IO ()
 reifyDatatypeWithConNameTest =
   $(do info <- reifyDatatype 'Just
-       let a = VarT (mkName "a")
        validateDI info
          DatatypeInfo
           { datatypeContext = []
@@ -546,3 +560,49 @@
 reifyConstructorTest =
   $(do info <- reifyConstructor 'Just
        validateCI info justCI)
+
+#if MIN_VERSION_base(4,7,0)
+importedEqualityTest :: IO ()
+importedEqualityTest =
+  $(do info <- reifyDatatype ''(:~:)
+       let [a,b] = map (VarT . mkName) ["a","b"]
+           k     = mkName "k"
+           kKind = varKCompat k
+       validateDI info
+         DatatypeInfo
+           { datatypeContext = []
+           , datatypeName    = ''(:~:)
+           , datatypeVars    = [SigT a kKind, SigT b kKind]
+           , datatypeVariant = Datatype
+           , datatypeCons    =
+               [ ConstructorInfo
+                   { constructorName       = 'Refl
+                   , constructorVars       = [KindedTV k starK]
+                     -- This shouldn't happen, ideally. See #37.
+
+                   , constructorContext    = [equalPred a b]
+                   , constructorFields     = []
+                   , constructorStrictness = []
+                   , constructorVariant    = NormalConstructor } ]
+           }
+   )
+#endif
+
+#if MIN_VERSION_template_haskell(2,8,0)
+kindSubstTest :: IO ()
+kindSubstTest =
+  $(do k1 <- newName "k1"
+       k2 <- newName "k2"
+       a  <- newName "a"
+       let ty = ForallT [KindedTV a (VarT k1)] [] (VarT a)
+           substTy = applySubstitution (Map.singleton k1 (VarT k2)) ty
+
+           checkFreeVars :: Type -> [Name] -> Q ()
+           checkFreeVars t freeVars =
+             unless (freeVariables t == freeVars) $
+               fail $ "free variables of " ++ show t ++ " should be " ++ show 
freeVars
+
+       checkFreeVars ty      [k1]
+       checkFreeVars substTy [k2]
+       [| return () |])
+#endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/th-abstraction-0.2.3.0/th-abstraction.cabal 
new/th-abstraction-0.2.6.0/th-abstraction.cabal
--- old/th-abstraction-0.2.3.0/th-abstraction.cabal     2017-06-26 
23:04:22.000000000 +0200
+++ new/th-abstraction-0.2.6.0/th-abstraction.cabal     2017-09-05 
04:55:33.000000000 +0200
@@ -1,5 +1,5 @@
 name:                th-abstraction
-version:             0.2.3.0
+version:             0.2.6.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

++++++ th-abstraction.cabal ++++++
name:                th-abstraction
version:             0.2.6.0
x-revision: 1
synopsis:            Nicer interface for reified information about data types
description:         This package normalizes variations in the interface for
                     inspecting datatype information via Template Haskell
                     so that packages and support a single, easier to use
                     informational datatype while supporting many versions
                     of Template Haskell.
license:             ISC
license-file:        LICENSE
author:              Eric Mertens
maintainer:          [email protected]
copyright:           2017 Eric Mertens
homepage:            https://github.com/glguy/th-abstraction
bug-reports:         https://github.com/glguy/th-abstraction/issues
category:            Development
build-type:          Simple
extra-source-files:  ChangeLog.md README.md
cabal-version:       >=1.10
tested-with:         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
  location: https://github.com/glguy/th-abstraction.git

library
  exposed-modules:     Language.Haskell.TH.Datatype
  other-modules:       Language.Haskell.TH.Datatype.Internal
  build-depends:       base             >=4.3   && <5,
                       ghc-prim,
                       template-haskell >=2.5   && <2.14,
                       containers       >=0.4   && <0.6
  hs-source-dirs:      src
  default-language:    Haskell2010

test-suite unit-tests
  other-modules:       Harness
                       Types
  type:                exitcode-stdio-1.0
  main-is:             Main.hs
  build-depends:       th-abstraction, base, containers, template-haskell
  hs-source-dirs:      test
  default-language:    Haskell2010

Reply via email to