fclabels

First class accessor labels implemented as lenses. https://github.com/sebastiaanvisser/fclabels

Version on this page:2.0.3.2
LTS Haskell 8.12:2.0.3.2
Stackage Nightly 2017-04-26:2.0.3.2
Latest on Hackage:2.0.3.2
BSD3 licensed by Sebastiaan Visser, Erik Hesselink, Chris Eidhof, Sjoerd Visscher with lots of help and feedback from others.

fclabels: first class accessor labels

This package provides first class labels that can act as bidirectional record fields. The labels can be derived automatically using Template Haskell which means you don't have to write any boilerplate yourself. The labels are implemented as lenses and are fully composable. Lenses can be used to get, set and modify parts of a data type in a consistent way.

See Data.Label for an introductory explanation.

Total and partial lenses

Internally lenses do not use Haskell functions directly, but are implemented as categories. Categories allow the lenses to be run in custom computational contexts. This approach allows us to make partial lenses that point to fields of multi-constructor datatypes in an elegant way.

See Data.Label.Partial for the use of partial labels.

Monomorphic and polymorphic lenses

We have both polymorphic and monomorphic lenses. Polymorphic lenses allow updates that change the type. The types of polymorphic lenses are slightly more verbose than their monomorphic counterparts, but their usage is similar. Because monomorphic lenses are built by restricting the types of polymorphic lenses they are essentially the same and can be freely composed with eachother.

See Data.Label.Mono and Data.Label.Poly for the difference between polymorphic and monomorphic lenses.

Using fclabels

To simplify working with labels we supply both a set of labels for Haskell's base types, like lists, tuples, Maybe and Either, and we supply a set of combinators for working with labels for values in the Reader and State monad.

See Data.Label.Base and Data.Label.Monadic for more information.

On Hackage: http://hackage.haskell.org/package/fclabels

Introduction: http://fvisser.nl/post/2013/okt/1/fclabels-2.0.html

Changes

CHANGELOG

2.0.3.2
- Allow HUnit 1.5.*

2.0.3.1

- Allow HUnit 1.4.*.
- Fix test suite on GHC 7.4.

2.0.3

- Support GHC 8.

2.0.2.3 to 2.0.2.4

- Allow transformers 0.5.*.

2.0.2.2 to 2.0.2.3

- Allow HUnit 1.3.*

2.0.2.1 to 2.0.2.2

- Restored support for GHC 7.4.

2.0.2 to 2.0.2.1

- Support for GHC 7.10 by widening TH dependencies.

2.0.2
- Add `for` as a synonym for `>-` to avoid a clash with the Arrows extension.

2.0.1.1

- Allow mtl 2.2.* and transformers 0.4.*
- Allow template-haskell 2.9.* in test-suite

2.0.0.5 to 2.0.1

- Widened TH dependencies.

2.0.0.4 -> 2.0.0.5
- Add Bug-Reports url again.

2.0.0.3 -> 2.0.0.4
- Include CHANGELOG in source distribution.

2.0.0.2 -> 2.0.0.3
- Support GHC 7.0. Note that there seems to be a problem with the
appicative syntax, see test cases.

2.0.0.1 -> 2.0.0.2
- Fix deriving with data types with more than 24 fields.

2.0 -> 2.0.0.1
- Remove warnings on generated labels with OverloadedStrings.

1.1.7.1 -> 2.0

- Introduced polymorphic lenses.
- Lenses are now based on getters and modifiers, not getters and setters.
- Pure lenses are now named Total lenses.
- Maybe lenses are now named Partial lenses.
- Introduced Failing lenses that preserve errors.
- Generalized Point datatype.
- Removed unused monadic functions for partial lenses.
- Added ArrowFail type class.
- Added lenses for base types. (tuples, lists, Maybe, Either)
- Isomorphisms now uses regular function space for base morphism.
- Swapped iso for more useful inv.
- Introduced iso to more easily lift isomorphisms into lenses.
- Removed mainly unused bimap.
- Added derivation of lenses as expressions.
- Convert record declarations directly into fclabels variants.
- Allow deriving lenses for GADTs.
- Added reasonably sophisticated totality checker for GADT labels.
- Derived lenses can now fail in either ArrowZero or ArrowFail.
- Alternative instance for Point.
- Vertical composition for multi-constructor data types.
- Extensive test suite.
- Fully documented.

1.1.7 -> 1.1.7.1

- Removed unicode from cabal file to help messed up build servers.

1.1.6 -> 1.1.7

- Fixed compilation issue on newer GHC using clang.
Thanks to 唐鳳.

1.1.5 -> 1.1.6

- Exposed generic TH derive function.
Thanks to Bram Schuur.

1.1.4.3 -> 1.1.5

- Added `modifyAndGet` helper function.
Thanks to Nikita Volkov.

1.1.4.2 -> 1.1.4.3

- Make compilable against Template Haskell 2.8.
Thanks to mgsloan for the pull request.
- Added TH derivation support for special kinded type variables.

1.1.4 -> 1.1.4.2

- Make compilable against Template Haskell 2.8.
Thanks to Shimuuar for the pull request.

1.1.4 -> 1.1.4.1

- Changed infix type variables to named type variables.
This makes fclabels compile with GHC > 7.6.
- Added the `osi` (flipped iso) again.

1.1.3 -> 1.1.4

- Added function to derive labels for a single datatype.

1.1.1.0 -> 1.1.2

- Added partial set/modify versions that act as identity when the
constructor field is not available.

1.1.1.0 -> 1.1.1.1

- Relax dependency on transformers to include 0.3.0.0.

1.1.0.2 -> 1.1.1.0

- Added mkLabelsWith function to derive labels with custom names.
Thanks to Evan Laforge for the patch!

1.1.0.1 -> 1.1.0.2

- Fixed bug in `id` definition for `Lens (~>)`.
Thanks to yczhang89 for reporting!

1.1.0 -> 1.1.0.1

- Relax constraint on Template Haskell for GHC 7.4.

1.0.4 -> 1.1.0

- Fixed error in derived code in combination with -XMonoLocalBinds.
- Lowered the priority of =: operator.
- Added the =. operator for modification in state monads.

1.0.4 -> 1.0.5

- Relaxed Template Haskell dependency constraint for GHC 7.4
- Relaxed transformers dependency constraint
Thanks to Claude Heiland-Allen

1.0.3 -> 1.0.4

- Bugfix to compile on GHC 6.12 again.

1.0.2 -> 1.0.3

- Deriving labels for datatypes from other modules now works also when
imported qualified.

1.0.1 -> 1.0.2

- Allow generating monomorphic labels.
- Prettify type variables in TH-derived code.

1.0 -> 1.0.1

- Some documentation cleanups.
- Major performance improvements in setting and modifying values by
inlining most label functions.
Thanks to Anpheus for benchmarking!

0.11.2 -> 1.0
- Added abstract arrow based core module.
- Allow both pure and failing labels to be derived.
- Major API and documentation cleanup.
- Renamed lots of exposed function names.

0.11.1.1 -> 0.11.2

- Relaxed Template Haskell dependency constraint for GHC 7.2
- Removed redundant import warnings.

0.11.1 -> 0.11.1.1

- Improved TH support for multiple constructor datatypes.

0.9.1 -> 0.11.0

- Monadic labels now build against mtl.
- Separate module for core/non-core code.
- Code cleanups, especially the TH code.

0.4.2 -> 0.9.1

- Added askM and localM for running lenses inside MonadReader.
- Minor documentaion update.
- Exported Point internals.
- Renamed Label to Lens.

0.9.1 -> 0.11.0

- Monadic labels now build against mtl.
- Separate module for core/non-core code.
- Code cleanups, especially the TH code.

0.4.2 -> 0.9.1

- Added askM and localM for running lenses inside MonadReader.
- Minor documentaion update.
- Exported Point internals.
- Renamed Lens to Bijection, which is more correct.
- Renamed Label to Lens.

0.4.2 -> 0.4.3

- Added askM and locaM for running labels inside MonadReader.

0.4.2 -> 1.0.0

- Added askM and localM for running lenses inside MonadReader.
- Minor documentaion update.
- Exported Point internals.
- Renamed Lens to Bijection, which is more correct.
- Renamed Label to Lens.

0.4.2 -> 0.4.3

- Added askM and locaM for running labels inside MonadReader.
- Minor documentaion update.
- Exported Point internals.
- Renamed Lens to Bijection, which is more correct.
comments powered byDisqus