generic-labels: Generically extract and replace collections of record fields

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]

Handle various conversion operations between record types, such as projecting out a collection of fields from a record, or plugging in values for a subset of the fields of a larger record.

Works both with built-in Haskell records, as well as explicitly labelled types ( #label := value ) :: ( "label" := Type ) .

Project out a smaller record using project:

  data IBXD x = IBXD { i :: Int, b :: Bool, x :: x, d :: Double }
    deriving stock Generic
  data XI x = XI { x :: c, i :: Int }
    deriving stock Generic

Plug in a subset of fields using inject:

  xi_into_ibxd :: XI x -> IBXD x -> IBXD x
  xi_into_ibxd = inject

Create a record out of two collections of arguments using adapt:

  xi_plus_bd_makes_ibxd :: XI x -> ( "b" := Bool, "d" := Double ) -> IBXD x
  xi_plus_bd_makes_ibxd = adapt

See also the library's readme.


Change log
Dependencies base (>=4.14 && <4.17), generic-lens-core (>=2.0 && <2.2) [details]
License BSD-3-Clause
Author Sam Derbyshire
Maintainer Sam Derbyshire
Category Data, Generics, Records
Home page
Bug tracker
Source repo head: git clone git://
Uploaded by sheaf at 2021-02-09T10:41:05Z


[Index] [Quick Jump]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees