fresnel: high-powered optics in a small package

[ bsd3, control, library ] [ Propose Tags ] [ Report a vulnerability ]
Versions [RSS] 0.0.0.0, 0.0.0.1, 0.0.0.2, 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.8), foldable1-classes-compat (>=0.1 && <0.2), hashable (>=1.3 && <1.5), profunctors (>=5.6 && <5.7), semigroupoids (>=6 && <6.1), transformers (>=0.4 && <0.7), unordered-containers (>=0.2 && <0.3) [details]
License BSD-3-Clause
Copyright 2021–2024 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 2024-10-05T01:00:34Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 313 total (10 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for fresnel-0.1.0.1

[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, semigroupoids, and unordered-containers. On the other hand, prolens requires even fewer dependencies: only base.