matchable-th 0.1.0.0 → 0.1.1.0
raw patch · 4 files changed
+29/−14 lines, 4 filesdep ~basedep ~template-haskelldep ~th-abstractionPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base, template-haskell, th-abstraction
API changes (from Hackage documentation)
Files
- CHANGELOG.md +5/−0
- README.md +12/−0
- matchable-th.cabal +6/−6
- src/Data/Matchable/TH.hs +6/−8
CHANGELOG.md view
@@ -1,3 +1,8 @@+# 0.1.1.0++- Depends on "th-abstraction" >= 0.3, rather than < 0.3 at+ previous version.+ # 0.1.0.0 - Initial release.
README.md view
@@ -34,6 +34,18 @@ import Data.Bimatchable import Data.Matchable.TH +-- Most simple case+data BiF a b = BiF0 | BiF1 a b++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) instance Eq2 BiG where
matchable-th.cabal view
@@ -1,5 +1,5 @@ name: matchable-th-version: 0.1.0.0+version: 0.1.1.0 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: >=1.10+cabal-version: >=2.0 source-repository head type: git@@ -21,10 +21,10 @@ library hs-source-dirs: src exposed-modules: Data.Matchable.TH- build-depends: base >=4.9 && <5,- matchable >=0.1.2,- template-haskell >= 2.4 && < 2.15,- th-abstraction+ build-depends: base >= 4.10 && <5,+ matchable >= 0.1.2,+ template-haskell >= 2.4 && < 2.17,+ th-abstraction >= 0.3.0.0 ghc-options: -Wall default-language: Haskell2010
src/Data/Matchable/TH.hs view
@@ -45,16 +45,17 @@ 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 (removeSig <$> dtVars)+ tyA : rest' = reverse (VarT . boundName <$> dtVars) dtFunctor = foldr (flip AppT) (ConT name) rest' - removeSig (SigT a _) = a- removeSig a = a- f <- newName "f" let mkMatchClause (ConstructorInfo ctrName _ _ fields _ _) =@@ -224,11 +225,8 @@ makeBizipMatchWith' name = do info <- reifyDatatype name let DatatypeInfo { datatypeVars = dtVars , datatypeCons = cons } = info- tyB : tyA : rest' = reverse (removeSig <$> dtVars)+ tyB : tyA : rest' = reverse (VarT . boundName <$> dtVars) dtFunctor = foldr (flip AppT) (ConT name) rest'-- removeSig (SigT a _) = a- removeSig a = a f <- newName "f" g <- newName "g"