barbies-th 0.1.1 → 0.1.2
raw patch · 3 files changed
+18/−6 lines, 3 filesdep ~barbiesdep ~template-haskellPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: barbies, template-haskell
API changes (from Hackage documentation)
Files
- CHANGELOG.md +4/−0
- barbies-th.cabal +4/−4
- src/Data/Barbie/TH.hs +10/−2
CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for barbies-th +## 0.1.2++* `declareBareB` now derives `DistributiveD`+ ## 0.1.1 -- 2020/04/19 * Improved the deriving mechanism; deriving clauses within `declareBareB` are translated into `deriving via Barbie ...`
barbies-th.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: barbies-th-version: 0.1.1+version: 0.1.2 synopsis: Create strippable HKD via TH description: Please see Data.Barbie.TH bug-reports: https://github.com/fumieval/barbies-th@@ -8,7 +8,7 @@ license-file: LICENSE author: Fumiaki Kinoshita maintainer: fumiexcel@gmail.com-copyright: Copyright (c) 2019 Fumiaki Kinoshita+copyright: Copyright (c) 2020 Fumiaki Kinoshita category: Data, Generics extra-source-files: CHANGELOG.md, README.md @@ -16,8 +16,8 @@ exposed-modules: Data.Barbie.TH other-extensions: RankNTypes, PolyKinds, DataKinds, KindSignatures, TemplateHaskell, TypeFamilies build-depends: base >= 4.12- , template-haskell >= 2.14 && <2.16- , barbies ^>= 2.0+ , template-haskell >= 2.14 && <2.17+ , barbies ^>= 2.0.1 hs-source-dirs: src default-language: Haskell2010 ghc-options: -Wall
src/Data/Barbie/TH.hs view
@@ -25,6 +25,7 @@ import GHC.Generics (Generic) import Control.Applicative import Data.Functor.Identity (Identity(..))+import Data.Functor.Compose (Compose(..)) -- | barbies doesn't care about field names, but they are useful in many use cases class FieldNamesB b where@@ -32,8 +33,9 @@ bfieldNames :: IsString a => b (Const a) -- | Transform a regular Haskell record declaration into HKD form.--- 'BareB', 'FieldNamesB', 'FunctorB', 'TraversableB', 'ApplicativeB' and--- 'ConstraintsB' instances are derived.+-- 'BareB', 'FieldNamesB', 'FunctorB', 'DistributiveB',+-- 'TraversableB', 'ApplicativeB' and 'ConstraintsB' instances are+-- derived. -- -- For example, --@@ -88,6 +90,12 @@ appE (conE conName) (appE (varE 'f) . varE <$> xs)+ )+ instance DistributiveB $(datC) where+ bdistribute fb = $(foldl'+ appE+ (conE conName)+ [ [| Compose ($(varE fd) <$> fb) |] | (fd, _, _) <- fields ] ) instance TraversableB $(datC) where btraverse f $(conP conName $ map varP xs) = $(fst $ foldl'