barbies-th 0.1.4 → 0.1.5
raw patch · 3 files changed
+18/−2 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +4/−0
- barbies-th.cabal +1/−1
- src/Barbies/TH.hs +13/−1
CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for barbies-th +## 0.1.5++* It now generates `ConstraintsB` and `ApplicativeB` declarations without generics+ ## 0.1.4 * Renamed `Data.Barbie.TH` to `Barbies.TH`, leaving `Data.Barbie.TH` deprecated
barbies-th.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: barbies-th-version: 0.1.4+version: 0.1.5 synopsis: Create strippable HKD via TH description: Please see Data.Barbie.TH bug-reports: https://github.com/fumieval/barbies-th
src/Barbies/TH.hs view
@@ -23,6 +23,7 @@ import Data.String import Data.Foldable (foldl') import Barbies+import Barbies.Constraints import Barbies.Bare import Data.Functor.Product import GHC.Generics (Generic)@@ -94,6 +95,10 @@ -- variables. vanillaType = foldl' appT (conT dataName) (varT . varName <$> tvbs) + types = [t | (_, _, t) <- fields]++ varCstr <- newName "c"+ let datC = vanillaType `appT` conT ''Covered decs <- [d| instance BareB $(vanillaType) where@@ -130,8 +135,15 @@ (appE (varE 'f) . varE <$> xs) ) {-# INLINE btraverse #-}- instance ConstraintsB $(datC)+ instance ConstraintsB $(datC) where+ type AllB $(varT varCstr) $(datC) = $(foldl appT (tupleT (length types)) [varT varCstr `appT` pure t | t <- types])+ baddDicts $(conP conName $ map varP xs) = $(foldl'+ (\r x -> [|$(r) (Pair Dict $(varE x))|])+ (conE conName) xs) instance ApplicativeB $(datC) where+ bpure x = $(foldl'+ (\r _ -> [|$(r) x|])+ (conE conName) xs) bprod $(conP conName $ map varP xs) $(conP conName $ map varP ys) = $(foldl' (\r (x, y) -> [|$(r) (Pair $(varE x) $(varE y))|]) (conE conName) (zip xs ys))