barbies-th: Create strippable HKD via TH

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]


Please see Data.Barbie.TH

[Skip to Readme]


Versions 0, 0.1, 0.1.1, 0.1.2, 0.1.2, 0.1.3, 0.1.4, 0.1.5, 0.1.7, 0.1.8, 0.1.9, 0.1.10, 0.1.11
Change log
Dependencies barbies (>=2.0.1 && <2.1), base (>=4.12), template-haskell (>=2.14 && <2.17) [details]
License BSD-3-Clause
Copyright Copyright (c) 2020 Fumiaki Kinoshita
Author Fumiaki Kinoshita
Category Data, Generics
Bug tracker
Uploaded by FumiakiKinoshita at 2020-05-09T10:43:20Z


[Index] [Quick Jump]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Readme for barbies-th-0.1.2

[back to package description]


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
    }  |]


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.