MyNixOS website logo
Description

simplified import of elementary lens-family combinators.

This module, Lens.Simple, just re-exports the main modules from Russell O'Connor's lens-family package, the original van Laarhoven-O'Connor lens library. lens-family is particularly remarkable for its minute number of dependencies: (apart from mtl they are all ghc 'boot' libraries); but more importantly for its extreme conceptual simplicity and theoretical soundness. Much of the material it contains is well-explained, from a tutorial point of view, by lens-tutorial It is independent, self-standing and readily intelligible apart from any darker more general system of combinators that might attempt to extend it. Much of it ought to be in the Prelude.

Convenient import of the elementary combinators from lens-family, however, a little complicated. The idea of this trivial module, then, is just to make a sort of low-powered, minimal-dependency, lens-family equivalent of the 800 lb gorilla of lens library imports:

import Control.Lens

namely, the light-weight and elegant:

import Lens.Simple

Check it out, it's even one character shorter!

The material in lens-tutorial will work fine if you make this substitution in the underlying source and follow along as prompted.

As another illustration of the simplicity of the fundamental van Laarhoven-O'Connor lens combinators - and their homogeneity with Control.Lens - note that the gloss pong example from the lens library examples directory - which continues to be among the best introductory lens tutorials precisely by saying nothing - requires only this abbreviating change of imports.

If you make that program more complicated, you might of course end up needing the more sophisticated material in Control.Lens and its immense mass of dependencies. On the other hand, you might just need some of the additional material present in the similarly demystifying microlens or microlens-th and the associated modules.

This module was originally intended to simplify the use of packages that follow the original promise of the van Laarhoven-O'Connor lenses. Correct practice is to export lenses without depending on a lens-library, where possible. In basic cases these just use familiar Prelude types, after all. Examples of best practices in this respect are e.g. lens-family-th which doesn't depend on lens-family despite its name and pipes-related packages like pipes-bytestring and pipes-group.

Lens.Simple also re-exports convenient TH incantations like makeLenses from Dan Burton's associated lens-family-th.

lens-simple

Lens-Simple makes it easier to use the combinators from the original van Laarhoven-O'Connor lens library: Russell O'Connor's lens-family package. For various reasons, O'Connor's package has a rather complicated structure; our purpose here is to ignore all this. The zoom preferred here is from Lens.Family.State.Strict. makeLenses and makeTraversals & co are re-exported from Dan Burton's lens-family-th.

Metadata

Version

0.1.0.9

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