data-combinator-gen 0.1.0.0 → 0.1.0.1
raw patch · 5 files changed
+18/−3 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +5/−0
- README.md +2/−0
- data-combinator-gen.cabal +1/−1
- examples/Main.hs +3/−0
- src/Data/Combinators/TH.hs +7/−2
CHANGELOG.md view
@@ -1,5 +1,10 @@ # Revision history for data-combinator-gen +## 0.1.0.1 -- YYYY-mm-dd++* Added newtype support+ ## 0.1.0.0 -- YYYY-mm-dd * First version. Released on an unsuspecting world.+
README.md view
@@ -2,6 +2,8 @@ Generate a special combinator from any data type. +https://hackage.haskell.org/package/data-combinator-gen-0.1.0.0+ ## Description This library provides a function to generate a special combinator from any data
data-combinator-gen.cabal view
@@ -13,7 +13,7 @@ -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change-version: 0.1.0.0+version: 0.1.0.1 -- A short (one-line) description of the package. synopsis: Generate a special combinator from any data type.
examples/Main.hs view
@@ -8,6 +8,9 @@ import Data.Functor.Foldable -- Recursion schemes library import Data.Functor.Foldable.TH -- Recursion schemes makeBaseFunctor import Data.List (foldl')+import Data.Functor.Compose++makeCombinator ''Compose makeCombinator ''ListF
src/Data/Combinators/TH.hs view
@@ -28,7 +28,8 @@ -} makeCombinator :: Name -> Q [Dec] makeCombinator t = do- TyConI (DataD _ _ _ _ constructors _) <- reify t+ TyConI d <- reify t+ let constructors = typeInfo d pe <- genPE "f" (length constructors) @@ -40,8 +41,12 @@ ----- -- (2) makeCombinator auxiliary function -------- Generates a single function clause +-- Returns type constructors+typeInfo (DataD _ _ _ _ c _) = c+typeInfo (NewtypeD _ _ _ _ c _) = [c]++-- Generates a single function clause combinClause :: ([PatQ], [ExpQ]) -- Function arguments pattern -> (Con, Int) -- (Constructor, Indice of current constructor) -> ClauseQ