Automatic generation of record lenses for microlens


Version on this page:
LTS Haskell 22.29:
Stackage Nightly 2024-07-16:
Latest on Hackage:

See all snapshots microlens-th appears in

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

Module documentation for

This package lets you automatically generate lenses for data types; code was extracted from the lens package, and therefore generated lenses are fully compatible with ones generated by lens (and can be used both from lens and microlens).

This package is a part of the microlens family; see the readme on Github.


  • #167 Support th-abstraction 0.5.

  • #164, #165 Support template-haskell 2.19 (and GHC 9.6 by extension).

  • #161 Fix GHC 9.4 warning for using ~ without TypeOperators.

  • Port lens commit fae336e1, “Close over kind variables when computing fixed type variables”, fixing lens issue #972.

  • Allow building with template-haskell-2.18.

  • Port lens commit 66e199ee, fixing lens issue #945 — “Make the TH machinery handle PolyKinds more robustly”.

  • Fixup.

  • Changes needed for template-haskell-2.17.

  • Bumped th-abstraction.

  • Changes needed for template-haskell-2.16.

  • Backported changes needed for template-haskell-2.15.

  • Exported internal utilities from Lens.Micro.TH.Internal.

  • Bumped template-haskell version.

  • No more conditional Safe (see #122).


  • Bumped th-abstraction version.
  • Lens.Micro.TH is now properly marked as Safe or Trustworthy.
  • The -f-inlining flag is not supported anymore.

  • Bumped template-haskell version.

  • Bumped containers version.

  • Fixed lens bug #799 (makeFields instances violate coverage condition).


  • We now depend on th-abstraction (like lens itself).
  • Associated types are now supported.

  • Bumped the upper bound of template-haskell again.

Skipped (the tarball got corrupted).

  • Bumped the upper bound of template-haskell, as requested by @ocharles.

  • Added abbreviatedFields.

  • Ported a lens commit that (probably) makes lens generation deterministic. See issue #83.

  • Added makeClassy (and createClass).

  • Added forgotten copyright/authorship information.

  • The library is now compatible with GHC 8.

  • SimpleGetter and SimpleFold are no longer reexported.

  • Moved Getter and Fold from this package to microlens (they’re in Lens.Micro.Extras).

  • Bumped template-haskell (so that the package would compile with GHC HEAD).

  • Bumped microlens version to be able to use phantom.

  • Bumped microlens version again.

  • Bumped base version.
  • Bumped microlens version.

  • createClass was removed because it doesn’t seem to be useful without lensClass.
  • defaultFieldRules isn’t exported anymore – use camelCaseFields.

  • Package now compiles with -O2 and other optimisations by default.

  • Added makeLensesFor (and lensRulesFor).

  • Wrote a bit of documentation.

Initial release.