packages feed

matchable-th 0.1.1.0 → 0.1.1.1

raw patch · 4 files changed

+29/−27 lines, 4 filesdep ~th-abstractionPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: th-abstraction

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,3 +1,8 @@+# 0.1.1.1++- Use "th-abstraction" >= 0.4 to cover changes in forthcoming+  template-haskell-2.17 bundled in GHC 9.0+ # 0.1.1.0  - Depends on "th-abstraction" >= 0.3, rather than < 0.3 at
matchable-th.cabal view
@@ -1,5 +1,5 @@ name:                matchable-th-version:             0.1.1.0+version:             0.1.1.1 synopsis:            Generates Matchable instances using TemplateHaskell description:         This package provides TemplateHaskell function to generate                      instances of @Matchable@ and @Bimatchable@ type classes,@@ -11,7 +11,7 @@ category:            Functors build-type:          Simple extra-source-files:  README.md, CHANGELOG.md-cabal-version:       >=2.0+cabal-version:       2.0  source-repository head   type:     git@@ -24,11 +24,11 @@   build-depends:        base               >= 4.10       && <5,                         matchable          >= 0.1.2,                         template-haskell   >= 2.4 && < 2.17,-                        th-abstraction     >= 0.3.0.0+                        th-abstraction     >= 0.4.0.0   ghc-options:          -Wall   default-language:     Haskell2010 -test-suite th-examples+test-suite matchable-th-test   type:                exitcode-stdio-1.0   hs-source-dirs:      test   main-is:             th.hs
src/Data/Matchable/TH.hs view
@@ -12,9 +12,10 @@ import           Data.Monoid                  (Monoid (..)) import           Data.Semigroup               (Semigroup (..)) -import           Language.Haskell.TH+import           Language.Haskell.TH hiding (TyVarBndr(..)) import           Language.Haskell.TH.Datatype (ConstructorInfo (..),                                                DatatypeInfo (..), reifyDatatype)+import           Language.Haskell.TH.Datatype.TyVarBndr  -- | Build an instance of 'Matchable' for a data type. --@@ -45,15 +46,11 @@ makeZipMatchWith :: Name -> ExpQ makeZipMatchWith name = makeZipMatchWith' name >>= snd -boundName :: TyVarBndr -> Name-boundName (KindedTV a _) = a-boundName (PlainTV a)    = a- makeZipMatchWith' :: Name -> Q ((Q Cxt, Type), ExpQ) makeZipMatchWith' name = do   info <- reifyDatatype name   let DatatypeInfo { datatypeVars = dtVars , datatypeCons = cons } = info-      tyA : rest' = reverse (VarT . boundName <$> dtVars)+      tyA : rest' = reverse (VarT . tvName <$> dtVars)       dtFunctor = foldr (flip AppT) (ConT name) rest'    f <- newName "f"@@ -225,7 +222,7 @@ makeBizipMatchWith' name = do   info <- reifyDatatype name   let DatatypeInfo { datatypeVars = dtVars , datatypeCons = cons } = info-      tyB : tyA : rest' = reverse (VarT . boundName <$> dtVars)+      tyB : tyA : rest' = reverse (VarT . tvName <$> dtVars)       dtFunctor = foldr (flip AppT) (ConT name) rest'    f <- newName "f"
test/th.hs view
@@ -16,29 +16,29 @@ data F a = F0 | F1 a | F2 a a   deriving (Show, Eq, Functor) +$(deriveMatchable ''F)+ instance Eq1 F where   liftEq = liftEqDefault -$(deriveMatchable ''F)- -- Test case for using [] and tuples newtype G a = G [(a, Int, a)]   deriving (Show, Eq, Functor) +$(deriveMatchable ''G)+ instance Eq1 G where   liftEq = liftEqDefault -$(deriveMatchable ''G)- -- Test case for extra type variable data H a b = H0 a | H1 a b | H2 [Either a b]   deriving (Show, Eq, Functor) +$(deriveMatchable ''H)+ instance (Eq a) => Eq1 (H a) where   liftEq = liftEqDefault -$(deriveMatchable ''H)- {-  @$(deriveMatchable ''H)@ expands like below:@@ -57,54 +57,54 @@ data I a b = I a (F b) (Either [b] (a,b))   deriving (Show, Eq) +$(deriveMatchable ''I)+ instance (Eq a) => Eq1 (I a) where   liftEq = liftEqDefault  instance (Eq a) => Functor (I a) where   fmap = fmapRecovered -$(deriveMatchable ''I)- -- Test case for recursive type data J a = J0 | J1 (J a, Int) a (Int, J a)   deriving (Show, Eq, Functor) +$(deriveMatchable ''J)+ instance Eq1 J where   liftEq = liftEqDefault -$(deriveMatchable ''J)- -------------------------------  -- Most simple case data BiF a b = BiF0 | BiF1 a b +$(deriveBimatchable ''BiF)+ instance Eq2 BiF where   liftEq2 = liftEq2Default  instance Bifunctor BiF where   bimap = bimapRecovered -$(deriveBimatchable ''BiF)- -- Test case for using [], tuple, and another Bimatchable instance data BiG a b = BiG0 | BiG1 [a] [b] | BiG2 (Int, BiF a b) +$(deriveBimatchable ''BiG)+ instance Eq2 BiG where   liftEq2 = liftEq2Default  instance Bifunctor BiG where   bimap = bimapRecovered -$(deriveBimatchable ''BiG)- -- Test case for recursive type data BiH a b = BiH1 a b | BiH2 (BiH b a) (BiH a String) +$(deriveBimatchable ''BiH)+ instance Eq2 BiH where   liftEq2 = liftEq2Default  instance Bifunctor BiH where   bimap = bimapRecovered--$(deriveBimatchable ''BiH)