Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package ghc-th-abstraction for openSUSE:Factory checked in at 2022-10-13 15:43:11 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-th-abstraction (Old) and /work/SRC/openSUSE:Factory/.ghc-th-abstraction.new.2275 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-th-abstraction" Thu Oct 13 15:43:11 2022 rev:17 rq:1008525 version:0.4.5.0 Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-th-abstraction/ghc-th-abstraction.changes 2021-09-10 23:41:30.830572318 +0200 +++ /work/SRC/openSUSE:Factory/.ghc-th-abstraction.new.2275/ghc-th-abstraction.changes 2022-10-13 15:43:25.910888627 +0200 @@ -1,0 +2,18 @@ +Mon Sep 12 23:32:58 UTC 2022 - Peter Simons <psim...@suse.com> + +- Update th-abstraction to version 0.4.5.0. + ## 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 + using `reifyDatatype`. + +------------------------------------------------------------------- +Sat Jul 23 17:44:02 UTC 2022 - Peter Simons <psim...@suse.com> + +- Update th-abstraction to version 0.4.4.0. + ## 0.4.4.0 -- 2022.07.23 + * Support free variable substitution and infix resolution for + `PromotedInfixT` and `PromotedUInfixT` on `template-haskell-2.19.0.0` or + later. + +------------------------------------------------------------------- Old: ---- th-abstraction-0.4.3.0.tar.gz New: ---- th-abstraction-0.4.5.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-th-abstraction.spec ++++++ --- /var/tmp/diff_new_pack.h562UJ/_old 2022-10-13 15:43:26.414889611 +0200 +++ /var/tmp/diff_new_pack.h562UJ/_new 2022-10-13 15:43:26.422889627 +0200 @@ -1,7 +1,7 @@ # # spec file for package ghc-th-abstraction # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,7 +19,7 @@ %global pkg_name th-abstraction %bcond_with tests Name: ghc-%{pkg_name} -Version: 0.4.3.0 +Version: 0.4.5.0 Release: 0 Summary: Nicer interface for reified information about data types License: ISC ++++++ th-abstraction-0.4.3.0.tar.gz -> th-abstraction-0.4.5.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/th-abstraction-0.4.3.0/ChangeLog.md new/th-abstraction-0.4.5.0/ChangeLog.md --- old/th-abstraction-0.4.3.0/ChangeLog.md 2001-09-09 03:46:40.000000000 +0200 +++ new/th-abstraction-0.4.5.0/ChangeLog.md 2001-09-09 03:46:40.000000000 +0200 @@ -1,5 +1,15 @@ # Revision history for th-abstraction +## 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 + using `reifyDatatype`. + +## 0.4.4.0 -- 2022.07.23 +* Support free variable substitution and infix resolution for + `PromotedInfixT` and `PromotedUInfixT` on `template-haskell-2.19.0.0` or + later. + ## 0.4.3.0 -- 2021.08.30 * Make `applySubstitution` avoid capturing type variable binders when substituting into `forall`s. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/th-abstraction-0.4.3.0/src/Language/Haskell/TH/Datatype.hs new/th-abstraction-0.4.5.0/src/Language/Haskell/TH/Datatype.hs --- old/th-abstraction-0.4.3.0/src/Language/Haskell/TH/Datatype.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/th-abstraction-0.4.5.0/src/Language/Haskell/TH/Datatype.hs 2001-09-09 03:46:40.000000000 +0200 @@ -492,7 +492,7 @@ TyConI dec -> normalizeDecFor isReified dec #if MIN_VERSION_template_haskell(2,7,0) FamilyI dec instances -> - do let instances1 = map (repairDataFam dec) instances + do instances1 <- mapM (repairDataFam dec) instances instances2 <- mapM (normalizeDecFor isReified) instances1 case find p instances2 of Just inst -> return inst @@ -524,8 +524,8 @@ -- A version of repairVarKindsWith that does much more extra work to -- (1) eta-expand missing type patterns, and (2) ensure that the kind -- signatures for these new type patterns match accordingly. -repairVarKindsWith' :: [TyVarBndr_ flag] -> [Type] -> [Type] -repairVarKindsWith' dvars ts = +repairVarKindsWith' :: [TyVarBndrUnit] -> Maybe Kind -> [Type] -> Q [Type] +repairVarKindsWith' dvars dkind ts = let kindVars = freeVariables . map kindPart kindPart (KindedTV _ k) = [k] kindPart (PlainTV _ ) = [] @@ -536,8 +536,8 @@ tsKinds' = map sanitizeStars tsKinds extraTys = drop (length tsNoKinds) (bndrParams dvars) ts' = tsNoKinds ++ extraTys -- eta-expand - in applySubstitution (Map.fromList (zip kparams tsKinds')) $ - repairVarKindsWith dvars ts' + in fmap (applySubstitution (Map.fromList (zip kparams tsKinds'))) $ + repairVarKindsWith dvars dkind ts' -- Sadly, Template Haskell's treatment of data family instances leaves much @@ -556,54 +556,77 @@ repairDataFam :: Dec {- ^ family declaration -} -> Dec {- ^ instance declaration -} -> - Dec {- ^ instance declaration -} + Q Dec {- ^ instance declaration -} repairDataFam - (FamilyD _ _ dvars _) - (NewtypeInstD cx n ts con deriv) = - NewtypeInstD cx n (repairVarKindsWith' dvars ts) con deriv + (FamilyD _ _ dvars dk) + (NewtypeInstD cx n ts con deriv) = do + ts' <- repairVarKindsWith' dvars dk ts + return $ NewtypeInstD cx n ts' con deriv repairDataFam - (FamilyD _ _ dvars _) - (DataInstD cx n ts cons deriv) = - DataInstD cx n (repairVarKindsWith' dvars ts) cons deriv + (FamilyD _ _ dvars dk) + (DataInstD cx n ts cons deriv) = do + ts' <- repairVarKindsWith' dvars dk ts + return $ DataInstD cx n ts' cons deriv #else repairDataFam famD instD # if MIN_VERSION_template_haskell(2,15,0) - | DataFamilyD _ dvars _ <- famD + | DataFamilyD _ dvars dk <- famD , NewtypeInstD cx mbInstVars nts k c deriv <- instD , con :| ts <- decomposeType nts - = NewtypeInstD cx mbInstVars - (foldl' AppT con (repairVarKindsWith dvars ts)) - k c deriv + = do ts' <- repairVarKindsWith dvars dk ts + return $ NewtypeInstD cx mbInstVars (foldl' AppT con ts') k c deriv - | DataFamilyD _ dvars _ <- famD + | DataFamilyD _ dvars dk <- famD , DataInstD cx mbInstVars nts k c deriv <- instD , con :| ts <- decomposeType nts - = DataInstD cx mbInstVars - (foldl' AppT con (repairVarKindsWith dvars ts)) - k c deriv + = do ts' <- repairVarKindsWith dvars dk ts + return $ DataInstD cx mbInstVars (foldl' AppT con ts') k c deriv # elif MIN_VERSION_template_haskell(2,11,0) - | DataFamilyD _ dvars _ <- famD + | DataFamilyD _ dvars dk <- famD , NewtypeInstD cx n ts k c deriv <- instD - = NewtypeInstD cx n (repairVarKindsWith dvars ts) k c deriv + = do ts' <- repairVarKindsWith dvars dk ts + return $ NewtypeInstD cx n ts' k c deriv - | DataFamilyD _ dvars _ <- famD + | DataFamilyD _ dvars dk <- famD , DataInstD cx n ts k c deriv <- instD - = DataInstD cx n (repairVarKindsWith dvars ts) k c deriv + = do ts' <- repairVarKindsWith dvars dk ts + return $ DataInstD cx n ts' k c deriv # else - | FamilyD _ _ dvars _ <- famD + | FamilyD _ _ dvars dk <- famD , NewtypeInstD cx n ts c deriv <- instD - = NewtypeInstD cx n (repairVarKindsWith dvars ts) c deriv + = do ts' <- repairVarKindsWith dvars dk ts + return $ NewtypeInstD cx n ts' c deriv - | FamilyD _ _ dvars _ <- famD + | FamilyD _ _ dvars dk <- famD , DataInstD cx n ts c deriv <- instD - = DataInstD cx n (repairVarKindsWith dvars ts) c deriv + = do ts' <- repairVarKindsWith dvars dk ts + return $ DataInstD cx n ts' c deriv # endif #endif -repairDataFam _ instD = instD +repairDataFam _ instD = return instD -repairVarKindsWith :: [TyVarBndr_ flag] -> [Type] -> [Type] -repairVarKindsWith = zipWith stealKindForType +-- | @'repairVarKindsWith' tvbs mbKind ts@ returns @ts@, but where each element +-- has an explicit kind signature taken from a 'TyVarBndr' in the corresponding +-- position in @tvbs@, or from the corresponding kind argument in 'mbKind' if +-- there aren't enough 'TyVarBndr's available. An example where @tvbs@ can be +-- shorter than @ts@ can be found in this example from #95: +-- +-- @ +-- data family F :: Type -> Type +-- data instance F a = C +-- @ +-- +-- The @F@ has no type variable binders in its @data family@ declaration, and +-- it has a return kind of @Type -> Type@. As a result, we pair up @Type@ with +-- @VarT a@ to get @SigT a (ConT ''Type)@. +repairVarKindsWith :: [TyVarBndrUnit] -> Maybe Kind -> [Type] -> Q [Type] +repairVarKindsWith tvbs mbKind ts = do + extra_tvbs <- mkExtraKindBinders $ fromMaybe starK mbKind + -- This list should be the same length as @ts@. If it isn't, something has + -- gone terribly wrong. + let tvbs' = tvbs ++ extra_tvbs + return $ zipWith stealKindForType tvbs' ts -- If a VarT is missing an explicit kind signature, steal it from a TyVarBndr. stealKindForType :: TyVarBndr_ flag -> Type -> Type @@ -1306,6 +1329,16 @@ ForallVisT `fmap` mapM resolve_tvb_syns tvbs `ap` resolveTypeSynonyms body #endif +#if MIN_VERSION_template_haskell(2,19,0) + PromotedInfixT t1 n t2 -> do + t1' <- resolveTypeSynonyms t1 + t2' <- resolveTypeSynonyms t2 + return $ PromotedInfixT t1' n t2' + PromotedUInfixT t1 n t2 -> do + t1' <- resolveTypeSynonyms t1 + t2' <- resolveTypeSynonyms t2 + return $ PromotedUInfixT t1' n t2' +#endif _ -> defaultCase f -- | Expand all of the type synonyms in a 'TypeArg'. @@ -1493,29 +1526,41 @@ resolveInfixT (ForallVisT vs t) = ForallVisT <$> traverse (traverseTVKind resolveInfixT) vs <*> resolveInfixT t # endif +# if MIN_VERSION_template_haskell(2,19,0) +resolveInfixT (PromotedInfixT l o r) + = promotedT o `appT` resolveInfixT l `appT` resolveInfixT r +resolveInfixT t@PromotedUInfixT{} + = resolveInfixT =<< resolveInfixT1 (gatherUInfixT t) +# endif resolveInfixT t = return t gatherUInfixT :: Type -> InfixList -gatherUInfixT (UInfixT l o r) = ilAppend (gatherUInfixT l) o (gatherUInfixT r) +gatherUInfixT (UInfixT l o r) = ilAppend (gatherUInfixT l) o False (gatherUInfixT r) +# if MIN_VERSION_template_haskell(2,19,0) +gatherUInfixT (PromotedUInfixT l o r) = ilAppend (gatherUInfixT l) o True (gatherUInfixT r) +# endif gatherUInfixT t = ILNil t -- This can fail due to incompatible fixities resolveInfixT1 :: InfixList -> TypeQ resolveInfixT1 = go [] where - go :: [(Type,Name,Fixity)] -> InfixList -> TypeQ - go ts (ILNil u) = return (foldl (\acc (l,o,_) -> ConT o `AppT` l `AppT` acc) u ts) - go ts (ILCons l o r) = + go :: [(Type,Name,Bool,Fixity)] -> InfixList -> TypeQ + go ts (ILNil u) = return (foldl (\acc (l,o,p,_) -> mkConT p o `AppT` l `AppT` acc) u ts) + go ts (ILCons l o p r) = do ofx <- fromMaybe defaultFixity <$> reifyFixityCompat o - let push = go ((l,o,ofx):ts) r + let push = go ((l,o,p,ofx):ts) r case ts of - (l1,o1,o1fx):ts' -> + (l1,o1,p1,o1fx):ts' -> case compareFixity o1fx ofx of - Just True -> go ((ConT o1 `AppT` l1 `AppT` l, o, ofx):ts') r + Just True -> go ((mkConT p1 o1 `AppT` l1 `AppT` l, o, p, ofx):ts') r Just False -> push Nothing -> fail (precedenceError o1 o1fx o ofx) _ -> push + mkConT :: Bool -> Name -> Type + mkConT promoted = if promoted then PromotedT else ConT + compareFixity :: Fixity -> Fixity -> Maybe Bool compareFixity (Fixity n1 InfixL) (Fixity n2 InfixL) = Just (n1 >= n2) compareFixity (Fixity n1 InfixR) (Fixity n2 InfixR) = Just (n1 > n2) @@ -1532,11 +1577,17 @@ nameBase o2 ++ "??? [" ++ showFixity ofx2 ++ "] in the same infix type expression" -data InfixList = ILCons Type Name InfixList | ILNil Type - -ilAppend :: InfixList -> Name -> InfixList -> InfixList -ilAppend (ILNil l) o r = ILCons l o r -ilAppend (ILCons l1 o1 r1) o r = ILCons l1 o1 (ilAppend r1 o r) +data InfixList + = ILCons Type -- The first argument to the type operator + Name -- The name of the infix type operator + Bool -- 'True' if this is a promoted infix data constructor, + -- 'False' otherwise + InfixList -- The rest of the infix applications to resolve + | ILNil Type + +ilAppend :: InfixList -> Name -> Bool -> InfixList -> InfixList +ilAppend (ILNil l) o p r = ILCons l o p r +ilAppend (ILCons l1 o1 p1 r1) o p r = ILCons l1 o1 p1 (ilAppend r1 o p r) #else -- older template-haskell packages don't have UInfixT @@ -1788,6 +1839,12 @@ ForallVisT tvs' (applySubstitution subst' t) #endif +#if MIN_VERSION_template_haskell(2,19,0) + go (PromotedInfixT l c r) + = PromotedInfixT (go l) c (go r) + go (PromotedUInfixT l c r) + = PromotedUInfixT (go l) c (go r) +#endif go t = t subst_tvbs :: [TyVarBndr_ flag] -> (Map Name Type -> a) -> a @@ -1814,6 +1871,12 @@ ForallVisT tvs t' -> fvs_under_forall tvs (freeVariables t') #endif +#if MIN_VERSION_template_haskell(2,19,0) + PromotedInfixT l _ r + -> freeVariables l `union` freeVariables r + PromotedUInfixT l _ r + -> freeVariables l `union` freeVariables r +#endif _ -> [] where fvs_under_forall :: [TyVarBndr_ flag] -> [Name] -> [Name] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/th-abstraction-0.4.3.0/test/Harness.hs new/th-abstraction-0.4.5.0/test/Harness.hs --- old/th-abstraction-0.4.3.0/test/Harness.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/th-abstraction-0.4.5.0/test/Harness.hs 2001-09-09 03:46:40.000000000 +0200 @@ -40,7 +40,7 @@ validate equate x y = either fail (\_ -> [| return () |]) (equate x y) -- | If the arguments are equal up to renaming return @'Right' ()@, --- otherwise return a string exlaining the mismatch. +-- otherwise return a string explaining the mismatch. equateDI :: DatatypeInfo -> DatatypeInfo -> Either String () equateDI dat1 dat2 = do check "datatypeName" (nameBase . datatypeName) dat1 dat2 @@ -75,7 +75,7 @@ check (lbl ++ " equality") asEqualPred pred1 pred2 -- | If the arguments are equal up to renaming return @'Right' ()@, --- otherwise return a string exlaining the mismatch. +-- otherwise return a string explaining the mismatch. equateCI :: ConstructorInfo -> ConstructorInfo -> Either String () equateCI con1 con2 = do check "constructorName" (nameBase . constructorName) con1 con2 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/th-abstraction-0.4.3.0/test/Main.hs new/th-abstraction-0.4.5.0/test/Main.hs --- old/th-abstraction-0.4.3.0/test/Main.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/th-abstraction-0.4.5.0/test/Main.hs 2001-09-09 03:46:40.000000000 +0200 @@ -74,6 +74,7 @@ recordFamTest t46Test t73Test + t95Test #endif fixityLookupTest #if __GLASGOW_HASKELL__ >= 704 @@ -92,7 +93,10 @@ t80Test #endif #if MIN_VERSION_template_haskell(2,11,0) - t79Test + t79TestA +#endif +#if MIN_VERSION_template_haskell(2,19,0) + t79TestB #endif #if __GLASGOW_HASKELL__ >= 800 t37Test @@ -679,6 +683,30 @@ , constructorVariant = NormalConstructor }] } ) + +t95Test :: IO () +t95Test = + $(do info <- reifyDatatype 'MkT95 + let a = mkName "a" + aTvb = kindedTV a starK + aVar = VarT a + validateDI info + DatatypeInfo + { datatypeName = ''T95 + , datatypeContext = [] + , datatypeVars = [aTvb] + , datatypeInstTypes = [AppT ListT aVar] + , datatypeVariant = DataInstance + , datatypeCons = + [ ConstructorInfo + { constructorName = 'MkT95 + , constructorVars = [] + , constructorContext = [] + , constructorFields = [aVar] + , constructorStrictness = [notStrictAnnot] + , constructorVariant = NormalConstructor }] + } + ) #endif fixityLookupTest :: IO () @@ -829,6 +857,10 @@ test (ParensT (idAppT $ ConT ''Int)) (ConT ''Int) #endif +#if MIN_VERSION_template_haskell(2,19,0) + test (PromotedInfixT (idAppT $ ConT ''Int) '(:^:) (idAppT $ ConT ''Int)) + (PromotedInfixT (ConT ''Int) '(:^:) (ConT ''Int)) +#endif [| return () |]) t66Test :: IO () @@ -880,8 +912,8 @@ #endif #if MIN_VERSION_template_haskell(2,11,0) -t79Test :: IO () -t79Test = +t79TestA :: IO () +t79TestA = $(do let [a,b,c] = map mkName ["a","b","c"] t = ForallT [kindedTVSpecified a (UInfixT (VarT b) ''(:+:) (VarT c))] [] (ConT ''()) @@ -889,6 +921,24 @@ (ConT ''()) actual <- resolveInfixT t unless (expected == actual) $ + fail $ "resolveInfixT does not recur into the kinds of " + ++ "ForallT type variable binders: " + ++ unlines [ "Expected: " ++ pprint expected + , "Actual: " ++ pprint actual + ] + [| return () |]) +#endif + +#if MIN_VERSION_template_haskell(2,19,0) +t79TestB :: IO () +t79TestB = + $(do let [a,b,c] = map mkName ["a","b","c"] + t = ForallT [kindedTVSpecified a (PromotedUInfixT (VarT b) '(:^:) (VarT c))] [] + (ConT ''()) + expected = ForallT [kindedTVSpecified a (PromotedT '(:^:) `AppT` VarT b `AppT` VarT c)] [] + (ConT ''()) + actual <- resolveInfixT t + unless (expected == actual) $ fail $ "resolveInfixT does not recur into the kinds of " ++ "ForallT type variable binders: " ++ unlines [ "Expected: " ++ pprint expected diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/th-abstraction-0.4.3.0/test/Types.hs new/th-abstraction-0.4.5.0/test/Types.hs --- old/th-abstraction-0.4.3.0/test/Types.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/th-abstraction-0.4.5.0/test/Types.hs 2001-09-09 03:46:40.000000000 +0200 @@ -71,6 +71,8 @@ type (:+:) = Either +data MyPair a b = a :^: b + -- Data families data family T43Fam @@ -114,6 +116,9 @@ data family T73 a b data instance T73 Int b = MkT73 b + +data family T95 :: * -> * +data instance T95 [a] = MkT95 a #endif #if __GLASGOW_HASKELL__ >= 704 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/th-abstraction-0.4.3.0/th-abstraction.cabal new/th-abstraction-0.4.5.0/th-abstraction.cabal --- old/th-abstraction-0.4.3.0/th-abstraction.cabal 2001-09-09 03:46:40.000000000 +0200 +++ new/th-abstraction-0.4.5.0/th-abstraction.cabal 2001-09-09 03:46:40.000000000 +0200 @@ -1,5 +1,5 @@ name: th-abstraction -version: 0.4.3.0 +version: 0.4.5.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.*, GHC==9.0.1, 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.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 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.19, + template-haskell >=2.5 && <2.20, containers >=0.4 && <0.7 hs-source-dirs: src default-language: Haskell2010