MIT licensed by Li-yao Xia
Maintained by [email protected]
This version can be pinned in stack with:generic-data-0.3.0.0@sha256:86cac53570f45f5b1e5f54d8765d0a05f1674b3703e4dbb48a919f89c57b3cbc,1860

Module documentation for 0.3.0.0

  • Generic
    • Generic.Data
      • Generic.Data.Internal
        • Generic.Data.Internal.Compat
        • Generic.Data.Internal.Data
        • Generic.Data.Internal.Enum
        • Generic.Data.Internal.Functions
        • Generic.Data.Internal.Generically
        • Generic.Data.Internal.Meta
        • Generic.Data.Internal.Newtype
        • Generic.Data.Internal.Prelude
        • Generic.Data.Internal.Resolvers
        • Generic.Data.Internal.Show
        • Generic.Data.Internal.Utils
      • Generic.Data.Orphans
      • Generic.Data.Types

Generic data types in Haskell Hackage Build Status

Utilities for GHC.Generics.

Generic deriving for standard classes

Supported classes that GHC currently can’t derive: Semigroup, Monoid, Applicative, Alternative, Eq1, Ord1, Show1.

Other classes from base are also supported, even though GHC can already derive them:

  • Eq, Ord, Enum, Bounded, Show (standard);
  • Functor, Foldable, Traversable (via extensions, DeriveFunctor, etc.).

(Read is currently not implemented.)

To derive type classes defined elsewhere, it might be worth taking a look at one-liner.

Type metadata

Extract type names, constructor names, number and arities of constructors, etc..


Related links

generic-data aims to subsume generic deriving features of the following packages:

  • semigroups: generic Semigroup, Monoid, but with a heavy dependency footprint.
  • transformers-compat: generic Eq1, Ord1, Show1.
  • generic-deriving: doesn’t derive the classes in base (defines clones of these classes as a toy example); has Template Haskell code to derive Generic.

Here are other relevant links.


All contributions are welcome. Open an issue or a pull request on Github!

Changes

0.3.0.0

  • Add generic implementations of enumFrom, enumFromThen, enumFromTo, enumFromThenTo. They are actually required to be explicit for correct Enum instances. Thanks to Topsii.
  • Parameterize GEnum by a type-level option, and add FiniteEnum option to allow Enum to be derived for composite types. Thanks to Topsii.

0.2.0.0

  • Remove Generic.Data.Types.Map
  • Add Generic.Data.Data.Types.toData and fromData
  • Remove Defun module (subsumed by first-class-families package)

0.1.1.0

  • Add gconIndex
  • Interface for constructor tags
  • Type-level Meta accessors
  • Add basic Newtype functions

0.1.0.0

Released generic-data