generic-deriving: Generic programming library for generalised deriving.

[ bsd3, generics, library ] [ Propose Tags ]

This package provides functionality for generalising the deriving mechanism in Haskell to arbitrary classes. It was first described in the paper:

The current implementation integrates with the new GHC Generics. See http://www.haskell.org/haskellwiki/GHC.Generics for more information. Template Haskell code is provided for supporting older GHCs.

This library is organized as follows:

It is worth emphasizing that these modules are primarly intended for educational purposes. Many of the classes in these modules resemble other commonly used classes—for example, GShow from Generics.Deriving.Show resembles Show from base—but in general, the classes that generic-deriving defines are not drop-in replacements. Moreover, the generic defaults that generic-deriving provide often make simplifying assumptions that may violate expectations of how these classes might work elsewhere. For example, the generic default for GShow does not behave exactly like deriving Show would.

If you are seeking GHC.Generics-based defaults for type classes in base, consider using the generic-data library.


[Skip to Readme]
Versions [faq] 0.3, 0.3.1, 0.4, 1.0.1, 1.0.2, 1.0.3, 1.2.1, 1.2.2, 1.3.0, 1.3.1, 1.4.0, 1.5.0, 1.6, 1.6.1, 1.6.2, 1.6.3, 1.7.0, 1.8.0, 1.9.0, 1.10.0, 1.10.1, 1.10.2, 1.10.3, 1.10.4, 1.10.4.1, 1.10.5, 1.10.6, 1.10.7, 1.11, 1.11.1, 1.11.2, 1.12, 1.12.1, 1.12.2, 1.12.3, 1.12.4, 1.13, 1.13.1, 1.14 (info)
Change log CHANGELOG.md
Dependencies base (>=4.3 && <5), containers (>=0.1 && <0.7), ghc-prim (==0.*), template-haskell (>=2.4 && <2.18), th-abstraction (==0.4.*) [details]
License BSD-3-Clause
Copyright 2011-2013 Universiteit Utrecht, University of Oxford
Author José Pedro Magalhães
Maintainer generics@haskell.org
Category Generics
Home page https://github.com/dreixel/generic-deriving
Bug tracker https://github.com/dreixel/generic-deriving/issues
Source repo head: git clone https://github.com/dreixel/generic-deriving
Uploaded by ryanglscott at 2020-09-30T18:21:24Z
Distributions Arch:1.14, Debian:1.12.2, Fedora:1.13.1, FreeBSD:1.8.0, LTSHaskell:1.12.4, NixOS:1.14, Stackage:1.12.4, openSUSE:1.13.1
Downloads 109233 total (2458 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-09-30 [all 1 reports]

Modules

[Index] [Quick Jump]

Flags

NameDescriptionDefaultType
base-4-9

Use base-4.9 or later. This version of base uses a DataKinds-based encoding of GHC generics metadata.

EnabledAutomatic

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for generic-deriving-1.14

[back to package description]

generic-deriving: Generic programming library for generalised deriving

Hackage Hackage Dependencies Haskell Programming Language BSD3 License Build

This package provides functionality for generalising the deriving mechanism in Haskell to arbitrary classes. It was first described in the paper:

The current implementation integrates with the new GHC Generics. See http://www.haskell.org/haskellwiki/GHC.Generics for more information. Template Haskell code is provided for supporting older GHCs.

This library is organized as follows:

  • Generics.Deriving.Base defines the core functionality for GHC generics, including the Generic(1) classes and representation data types. On modern versions of GHC, this simply re-exports GHC.Generics from base. On older versions of GHC, this module backports parts of GHC.Generics that were not included at the time, including Generic(1) instances.

  • Generics.Deriving.TH implements Template Haskell functionality for deriving instances of Generic(1).

  • Educational code: in order to provide examples of how to define and use GHC.Generics-based defaults, this library offers a number of modules which define examples of type classes along with default implementations for the classes' methods. Currently, the following modules are provided:

    • Generics.Deriving.Copoint

    • Generics.Deriving.ConNames

    • Generics.Deriving.Enum

    • Generics.Deriving.Eq

    • Generics.Deriving.Foldable

    • Generics.Deriving.Functor

    • Generics.Deriving.Monoid

    • Generics.Deriving.Semigroup

    • Generics.Deriving.Show

    • Generics.Deriving.Traversable

    • Generics.Deriving.Uniplate

    It is worth emphasizing that these modules are primarly intended for educational purposes. Many of the classes in these modules resemble other commonly used classes—for example, GShow from Generics.Deriving.Show resembles Show from base—but in general, the classes that generic-deriving defines are not drop-in replacements. Moreover, the generic defaults that generic-deriving provide often make simplifying assumptions that may violate expectations of how these classes might work elsewhere. For example, the generic default for GShow does not behave exactly like deriving Show would.

    If you are seeking GHC.Generics-based defaults for type classes in base, consider using the generic-data library.

  • Generics.Deriving.Default provides newtypes that allow leveraging the generic defaults in this library using the DerivingVia GHC language extension.

  • Generics.Deriving re-exports Generics.Deriving.Base, Generics.Deriving.Default, and a selection of educational modules.