rank2classes 1.5.2 → 1.5.3
raw patch · 5 files changed
+40/−18 lines, 5 filesdep ~template-haskell
Dependency ranges changed: template-haskell
Files
- CHANGELOG.md +4/−0
- README.md +2/−2
- rank2classes.cabal +2/−2
- src/Rank2/TH.hs +30/−12
- test/MyModule.lhs +2/−2
CHANGELOG.md view
@@ -1,3 +1,7 @@+Version 1.5.3+---------------+* Fixed compilation with GHC 9.8.1 and `template-haskell` 2.22+ Version 1.5.2 --------------- * Fixed the generated TH instance contexts for GADTs.
README.md view
@@ -212,9 +212,9 @@ This package is one of several implementations of a pattern that is often called *Higher-Kinded Data*. Other examples include [hkd-lens](https://hackage.haskell.org/package/hkd-lens),-[barbies](https://hackage.haskell.org/package/barbies), and [hiddledy](https://hackage.haskell.org/package/higgledy).+[barbies](https://hackage.haskell.org/package/barbies), and [higgledy](https://hackage.haskell.org/package/higgledy). -Grammars are another use case that is almost, but not quite, completely unlike database records. See+Grammars are another use case that is almost, but not quite, entirely unlike database records. See [grammatical-parsers](https://github.com/blamario/grampa/tree/master/grammatical-parsers) or [construct](https://hackage.haskell.org/package/construct) for examples.
rank2classes.cabal view
@@ -1,5 +1,5 @@ name: rank2classes-version: 1.5.2+version: 1.5.3 synopsis: standard type constructor class hierarchy, only with methods of rank 2 types description: A mirror image of the standard type constructor class hierarchy rooted in 'Functor', except with methods of rank 2@@ -44,7 +44,7 @@ data-functor-logistic < 0.1 if flag(use-template-haskell)- build-depends: template-haskell >= 2.11 && < 2.21+ build-depends: template-haskell >= 2.11 && < 2.22 exposed-modules: Rank2.TH test-suite doctests
src/Rank2/TH.hs view
@@ -113,19 +113,35 @@ DataD _ nm tyVars kind cs _ -> return (nm, tyVars, kind, cs) NewtypeD _ nm tyVars kind c _ -> return (nm, tyVars, kind, [c]) _ -> fail "deriveApply: tyCon may not be a type synonym."- ++ let reifySynonyms (ConT name) = TH.reify name >>= reifySynonymInfo name+ reifySynonyms (AppT t1 t2) = AppT <$> reifySynonyms t1 <*> reifySynonyms t2+ reifySynonyms t = pure t+ reifySynonymInfo _ (TyConI (TySynD _ [] t)) = reifySynonyms t+ reifySynonymInfo name _ = pure (ConT name) #if MIN_VERSION_template_haskell(2,17,0)- let (KindedTV tyVar () (AppT (AppT ArrowT _) StarT)) = last tyVars+ reifyTVKindSynonyms (KindedTV v s k) = KindedTV v s <$> reifySynonyms k+#else+ reifyTVKindSynonyms (KindedTV v k) = KindedTV v <$> reifySynonyms k+#endif+ reifyTVKindSynonyms tv = pure tv+ lastVar <- reifyTVKindSynonyms (last tyVars)++#if MIN_VERSION_template_haskell(2,17,0)+ let (KindedTV tyVar _ (AppT (AppT ArrowT _) resultKind)) = lastVar instanceType = conT cls `TH.appT` foldl apply (conT tyConName) (init tyVars) apply t (PlainTV name _) = TH.appT t (varT name) apply t (KindedTV name _ _) = TH.appT t (varT name) #else- let (KindedTV tyVar (AppT (AppT ArrowT _) StarT)) = last tyVars+ let (KindedTV tyVar (AppT (AppT ArrowT _) resultKind)) = lastVar instanceType = conT cls `TH.appT` foldl apply (conT tyConName) (init tyVars) apply t (PlainTV name) = TH.appT t (varT name) apply t (KindedTV name _) = TH.appT t (varT name) #endif- ++ case resultKind of+ StarT -> pure ()+ _ -> fail ("Unexpected result kind: " <> show resultKind) putQ (Deriving tyConName tyVar) return (instanceType, cs) @@ -230,12 +246,12 @@ genFmapClause instanceType (GadtC [name] fieldTypes _resultType@(AppT initType (VarT tyVar))) = do Just (Deriving tyConName _tyVar) <- getQ putQ (Deriving tyConName tyVar)- let AppT classType t = instanceType+ let AppT _classType t = instanceType first (renameConstraintVars t initType <$>) <$> genFmapClause instanceType (NormalC name fieldTypes) genFmapClause instanceType (RecGadtC [name] fields _resultType@(AppT initType (VarT tyVar))) = do Just (Deriving tyConName _tyVar) <- getQ putQ (Deriving tyConName tyVar)- let AppT classType t = instanceType+ let AppT _classType t = instanceType first (renameConstraintVars t initType <$>) <$> genFmapClause instanceType (RecC name fields) genFmapClause instanceType (ForallC _vars _cxt con) = genFmapClause instanceType con @@ -371,12 +387,12 @@ genApClause unsafely instanceType (GadtC [name] fieldTypes _resultType@(AppT initType (VarT tyVar))) = do Just (Deriving tyConName _tyVar) <- getQ putQ (Deriving tyConName tyVar)- let AppT classType t = instanceType+ let AppT _classType t = instanceType first (renameConstraintVars t initType <$>) <$> genApClause unsafely instanceType (NormalC name fieldTypes) genApClause unsafely instanceType (RecGadtC [name] fields _resultType@(AppT initType (VarT tyVar))) = do Just (Deriving tyConName _tyVar) <- getQ putQ (Deriving tyConName tyVar)- let AppT classType t = instanceType+ let AppT _classType t = instanceType first (renameConstraintVars t initType <$>) <$> genApClause unsafely instanceType (RecC name fields) genApClause unsafely instanceType (ForallC _vars _cxt con) = genApClause unsafely instanceType con @@ -449,12 +465,12 @@ genFoldMapClause instanceType (GadtC [name] fieldTypes _resultType@(AppT initType (VarT tyVar))) = do Just (Deriving tyConName _tyVar) <- getQ putQ (Deriving tyConName tyVar)- let AppT classType t = instanceType+ let AppT _classType t = instanceType first (renameConstraintVars t initType <$>) <$> genFoldMapClause instanceType (NormalC name fieldTypes) genFoldMapClause instanceType (RecGadtC [name] fields _resultType@(AppT initType (VarT tyVar))) = do Just (Deriving tyConName _tyVar) <- getQ putQ (Deriving tyConName tyVar)- let AppT classType t = instanceType+ let AppT _classType t = instanceType first (renameConstraintVars t initType <$>) <$> genFoldMapClause instanceType (RecC name fields) genFoldMapClause instanceType (ForallC _vars _cxt con) = genFoldMapClause instanceType con @@ -500,12 +516,12 @@ genTraverseClause instanceType (GadtC [name] fieldTypes _resultType@(AppT initType (VarT tyVar))) = do Just (Deriving tyConName _tyVar) <- getQ putQ (Deriving tyConName tyVar)- let AppT classType t = instanceType+ let AppT _classType t = instanceType first (renameConstraintVars t initType <$>) <$> genTraverseClause instanceType (NormalC name fieldTypes) genTraverseClause instanceType (RecGadtC [name] fields _resultType@(AppT initType (VarT tyVar))) = do Just (Deriving tyConName _tyVar) <- getQ putQ (Deriving tyConName tyVar)- let AppT classType t = instanceType+ let AppT _classType t = instanceType first (renameConstraintVars t initType <$>) <$> genTraverseClause instanceType (RecC name fields) genTraverseClause instanceType (ForallC _vars _cxt con) = genTraverseClause instanceType con @@ -611,7 +627,9 @@ | name == from = VarT to | otherwise = VarT name renameConstraintVar from to (AppT a b) = AppT (renameConstraintVar from to a) (renameConstraintVar from to b)+#if MIN_VERSION_template_haskell(2,15,0) renameConstraintVar from to (AppKindT t k) = AppT (renameConstraintVar from to t) (renameConstraintVar from to k)+#endif renameConstraintVar from to (InfixT a op b) = InfixT (renameConstraintVar from to a) op (renameConstraintVar from to b) renameConstraintVar from to (UInfixT a op b) = UInfixT (renameConstraintVar from to a) op (renameConstraintVar from to b) renameConstraintVar from to (SigT t k) = SigT (renameConstraintVar from to t) (renameConstraintVar from to k)
test/MyModule.lhs view
@@ -212,9 +212,9 @@ This package is one of several implementations of a pattern that is often called *Higher-Kinded Data*. Other examples include [hkd-lens](https://hackage.haskell.org/package/hkd-lens),-[barbies](https://hackage.haskell.org/package/barbies), and [hiddledy](https://hackage.haskell.org/package/higgledy).+[barbies](https://hackage.haskell.org/package/barbies), and [higgledy](https://hackage.haskell.org/package/higgledy). -Grammars are another use case that is almost, but not quite, completely unlike database records. See+Grammars are another use case that is almost, but not quite, entirely unlike database records. See [grammatical-parsers](https://github.com/blamario/grampa/tree/master/grammatical-parsers) or [construct](https://hackage.haskell.org/package/construct) for examples.