barbies-th: Create strippable HKD via TH

[ bsd3, data, generics, library ] [ Propose Tags ]

Please see Data.Barbie.TH


[Skip to Readme]
Versions [faq] 0, 0.1
Change log CHANGELOG.md
Dependencies barbies (==2.0.*), base (>=4.12), template-haskell (>=2.14 && <2.16) [details]
License BSD-3-Clause
Copyright Copyright (c) 2019 Fumiaki Kinoshita
Author Fumiaki Kinoshita
Maintainer fumiexcel@gmail.com
Category Data, Generics
Bug tracker https://github.com/fumieval/barbies-th
Uploaded by FumiakiKinoshita at Thu Feb 13 11:09:14 UTC 2020
Distributions NixOS:0
Downloads 117 total (80 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2020-02-13 [all 1 reports]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for barbies-th-0.1

[back to package description]

barbies-th

Hackage Haskell CI

A wrapper library for barbies to generate strippable HKDs. It transforms the following declaration

declareBareB [d|
  data Foo = Foo
    { foo :: Int
    , bar :: String
    }  |]

into:

data Foo sw h = Foo
    { foo :: Wear sw h Int,
    , bar :: Wear sw h String
    } deriving Generic
instance BareB Foo
instance FieldNamesB (Foo Covered) where
  bfieldNames = Foo (Const "foo") (Const "bar")
instance ProductB (Foo Covered) where
  bprod (Foo xfoo xbar) (Foo yfoo ybar)
    = Foo (Pair xfoo yfoo) (Pair xbar ybar)
instance FunctorB (Foo Covered) where ...
instance TraversableB (Foo Covered) where ...
instance ConstraintsB (Foo Covered)
instance ProductBC (Foo Covered)

GHC sometimes takes very long time to compile code with generically derived instances, and it often fails to inline functions properly too. This package generates most instance methods by TH, reducing large amount of compilation time of the declarations and use sites.

Unlike higgledy which relies on in-memory representation using GHC.Generic, you don't have to worry about the performance, and you can benefit from various language features (e.g. -Wmissing-fields, RecordWildCards etc) even in higher-kinded form.