MyNixOS website logo
Description

high-powered optics in a small package.

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

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 lensandoptics, 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.

Metadata

Version

0.0.0.3

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows