BSD-3-Clause licensed by Edward Kmett, Artyom Kazak
Maintained by Steven Fontanella
This version can be pinned in stack with:microlens-,4703

Module documentation for

NOTE: If you're writing an app, you probably want microlens-platform – it has the most features. microlens is intended more for library writers who want a tiny lens library (after all, lenses are pretty useful for everything, not just for updating records!).

This library 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.

There's a longer readme on Github. It has a migration guide for lens users, a description of other packages in the family, a discussion of other lens libraries you could use instead, and so on.

Here are some usecases for this library:

  • You want to define lenses or traversals in your own library, but don't want to depend on lens. Having lenses available often make working with a library more pleasant.

  • You just want to be able to use lenses to transform data (or even just use over _1 to change the first element of a tuple).

  • You are new to lenses and want a small library to play with.

However, don't use this library if:

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

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

As already mentioned, 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.

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 depends on transformers-0.2 or above.


  • Added _Show, worded, and lined.

  • Added instance Ixed (NonEmpty a) for GHC >= 8.

  • Exported a coerce compatibility shim from Lens.Micro.Internal.

  • Fixed compilation on GHC 8.8 (thanks to @vmchale).

  • Reverted marking Lens.Micro.Internal as Trustworthy, see #122.


  • Added fixity declarations for +~ and -~ (thanks to Francesco Ariis).
  • Added rewriteOf and transformOf (thanks to @quasicomputational).
  • Added an instance Each (Either a a) (Either b b) a b, following lens’s suit.
  • Marked Lens.Micro.Internal as Trustworthy starting from GHC 7.8.


  • Added +~ and -~.
  • Marked #. and .# with INLINE.

  • Reexported <&> from Data.Functor (on recent versions of base).


  • Added <>~.
  • Added fixities for <%~, <<%~, <<.~.

  • Fixed compilation on GHC 8.4.

Skipped (the tarball got corrupted).

  • Added HasCallStack for some partial functions.

  • Added forOf_ and forOf.
  • Added an instance for Each (NonEmpty a) (available starting from GHC 8).

  • Fixed the Haddock crash on GHC 8 by removing default method implementations (each = traverse and ix = ixAt). If you had custom instances of Ixed or Each which relied on default methods, they’d stop working.

  • Added traverseOf and traverseOf_.
  • Changed fixities of #. and .# to the ones in the profunctors package. Those operators are only available from Lens.Micro.Internal, so this shouldn’t affect most users.

  • Added <&> (which makes lens creation easier).

  • Fixed markup in the .cabal file.
  • Added descriptions of other packages to Lens.Micro.

  • More changes to make microlens-platform more prominent.

  • Pointed to microlens-platform in the synopsis.

  • Added mapAccumLOf.

  • Added ?~.

  • Added forgotten copyright/authorship information.

  • Added singular.

  • Added strict and lazy.

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

  • 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.

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

  • 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.

  • 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, though).

  • Added non.

  • Added filtered.
  • Added Safe Haskell pragmas.

  • Added toListOf back.
  • Added to.

  • Added LensLike and LensLike'.
  • Added failing.

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

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

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

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

  • Added each.

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

First release.