fresnel: high-powered optics in a small package

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]

fresnel offers (non-indexed) profunctor optics composed with the lowly . operator.


[Skip to Readme]

Properties

Versions 0.0.0.0, 0.0.0.1, 0.0.0.2, 0.0.0.3, 0.0.0.3, 0.1.0.0, 0.1.0.1
Change log CHANGELOG.md
Dependencies base (>=4.14 && <5), containers (>=0.5 && <0.7), hashable (>=1.3 && <1.5), profunctors (>=5.6 && <5.7), transformers (>=0.4 && <0.7), unordered-containers (>=0.2 && <0.3) [details]
License BSD-3-Clause
Copyright 2021–2023 Rob Rix
Author Rob Rix
Maintainer rob.rix@me.com
Category Control
Home page https://github.com/fresnel/fresnel
Bug tracker https://github.com/fresnel/fresnel/issues
Source repo head: git clone https://github.com/fresnel/fresnel(fresnel)
Uploaded by robrix at 2023-11-27T18:11:59Z

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for fresnel-0.0.0.3

[back to package description]

fresnel: high-powered optics in a small package

CI status badge hackage

fresnel is yet another optics (aka functional references) package for Haskell.

diagram of the optical and profunctor hierarchies and their relationships to one another

The above image is interactive. Click to open it, and then hover over labels to highlight everything they include.

The name

Fresnel (pronounced approx. like “fray knell”) lenses are compact optics commonly seen in lighthouses, allowing much greater brightness or magnification than would otherwise be possible due to the size and weight of conventional glass optics.

It seemed like an apt metaphor for a pared-down optics library based on functions and using ghc’s constraint solver to do the heavy lifting.

Comparisons

Like optics, it uses profunctor optics rather than the Van Laarhoven representation. Like lens, it uses type synonyms and -XRankNTypes to compose optics with the . operator and allow ghc to deduce the (faux-)subtyping relationships between optics.

Like both of the above, but unlike prolens, fresnel offers a rich suite of optics to suit all tastes.

Unlike lens (but like optics), it goes to some effort to provide a sensibly-named hierarchy of optics to improve type errors. In optics this is provided by means of type families providing the subsumption relation and constraints; in fresnel, names, subsumption, and constraints are all provided by Is* typeclasses (e.g. IsPrism, IsTraversal, etc.) subclassing the profunctor classes directly.

Unlike lens, it doesn’t define any typeclasses to abstract over optics’ sources. It also has a comparatively minimal suite of combinators for complex compositions of projections, etc.

Unlike both lens and prolens, fresnel uses somewhat more approachable names where possible, e.g. Optional instead of AffineTraversal.

Unlike both lens and optics, fresnel (currently) has no support for indexed optics, or certain other baroque optics. Some of these would be simpler additions than others, and are likely to be added in the fullness of time.

Like prolens, and also unlike either of the others, fresnel requires a reasonably small set of dependencies: base, containers, profunctors, and unordered-containers. On the other hand, prolens requires even fewer dependencies: only base.