microlens

A tiny part of the lens library with no dependencies

http://github.com/aelve/microlens

Version on this page:0.4.4.0
LTS Haskell 19.13:0.4.12.0
Stackage Nightly 2022-06-30:0.4.12.0
Latest on Hackage:0.4.13.0

See all snapshots microlens appears in

BSD-3-Clause licensed by Edward Kmett, Artyom
Maintained by Artyom
This version can be pinned in stack with:microlens-0.4.4.0@sha256:023214e36ba565e95841b67dcf3ddf599498e7b469e19d37252beec99cb76953,3586

Module documentation for 0.4.4.0

This is an extract from lens (with no dependencies). It's not a toy lenses library, unsuitable for “real world”, but merely a small one. It is compatible with lens, and should have same performance. It also has better documentation.

Use this library:

  • if you want to define lenses or traversals in your own library, but don't want to depend on lens

  • if you are new to lenses and want a small library to play with, but don't want to use something “inferior” or have to relearn things when/if you switch to lens

Don't use this library:

  • if you need Isos, Prisms, indexed traversals, or actually anything else which isn't defined here (tho some indexed functions are available elsewhere – containers and vector provide them for their types, and ilist provides indexed functions for lists)

  • if you want a library with a clean, understandable implementation (in which case you're looking for lens-simple)

If you're writing an application which uses lenses more extensively, look at microlens-platform – it combines features of most other microlens packages (microlens-mtl, microlens-th, microlens-ghc).

If you want to export getters or folds and don't mind the contravariant dependency, please consider using microlens-contra.

There's a longer readme on Github, you should read it if you're interested about using this library.

If you haven't ever used lenses before, read this tutorial. (It's for lens, but it applies to microlens just as well.)

Note that microlens has no dependencies starting from GHC 7.10 (base-4.8). Prior to that, it has to depend on transformers-0.2 or above.

Changes

0.4.4.0

  • Added mapAccumLOf.

0.4.3.0

  • Added ?~.

0.4.2.1

  • Added forgotten copyright/authorship information.

0.4.2.0

  • Added singular.

0.4.1.0

  • Added strict and lazy.

0.4.0.1

  • Fixed a bug that wasn’t letting the package compile with GHC 8.0 (see issue #63).

0.4.0.0

  • Added folding.
  • Renamed Getter and Fold to SimpleGetter and SimpleFold and put them into Lens.Micro. Genuine Getter and Fold are available in microlens-contra.
  • Replaced Applicative (Const r) constraints with Monoid r because it’s the same thing but easier to understand.

0.3.5.1

  • Backported the fix for the bug that wasn’t letting the package compile with GHC 8.0 (see issue #63).

0.3.5.0

  • Added Lens.Micro.Extras with view, preview, Getter, and Fold. Now you no longer need microlens-mtl if the only thing you need from it is view.

0.3.4.1

  • Changed the description of the package from “A tiny part of the lens library which you can depend upon” to “A tiny part of the lens library with no dependencies” because the previous one was ambiguous (I admit I kinda liked that ambiguity, tho).

0.3.4.0

  • Added non.

0.3.3.0

  • Added filtered.
  • Added Safe Haskell pragmas.

0.3.2.0

  • Added toListOf back.
  • Added to.

0.3.1.0

  • Added LensLike and LensLike'.
  • Added failing.

0.3.0.0

  • Moved Lens.Micro.Classes into Lens.Micro.Internal.
  • Added <%~, <<%~, <<.~.
  • Added _head, _tail, _init, _last.

0.2.0.0

  • Removed toListOf.
  • Removed +~, -~, *~, //~ and the Lens.Micro.Extras module.

0.1.5.0

  • Added ix and at.
  • Added traversed.
  • Moved some things into Lens.Micro.Internal.
  • Bumped base version.

0.1.3.0

  • Moved some things into Lens.Micro.Type and Lens.Micro.Classes.
  • Each and Field* aren’t exported by Lens.Micro now.

0.1.2.0

  • Added each.

0.1.1.0

  • Added ASetter', which is useful because we can’t provide real Setter and Setter'.

0.1.0.0

First release.