/usr/share/doc/libghc-lens-doc/html/Control-Lens-TH.html is in libghc-lens-doc 4.15.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Control.Lens.TH</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="file:///usr/share/javascript/mathjax/MathJax.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_Control-Lens-TH.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Control-Lens-TH.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">lens-4.15.4: Lenses, Folds and Traversals</p></div><div id="content"><div id="module-header"><table class="info"><tr><th valign="top">Copyright</th><td>(C) 2012-16 Edward Kmett 2012-13 Michael Sloan</td></tr><tr><th>License</th><td>BSD-style (see the file LICENSE)</td></tr><tr><th>Maintainer</th><td>Edward Kmett <ekmett@gmail.com></td></tr><tr><th>Stability</th><td>experimental</td></tr><tr><th>Portability</th><td>non-portable</td></tr><tr><th>Safe Haskell</th><td>Trustworthy</td></tr><tr><th>Language</th><td>Haskell98</td></tr></table><p class="caption">Control.Lens.TH</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Constructing Lenses Automatically</a><ul><li><a href="#g:2">Lenses for data fields</a></li><li><a href="#g:3">Prisms</a></li><li><a href="#g:4">Wrapped</a></li></ul></li><li><a href="#g:5">Constructing Lenses Given a Declaration Quote</a><ul><li><a href="#g:6">Lenses for data fields</a></li><li><a href="#g:7">Prisms</a></li><li><a href="#g:8">Wrapped</a></li></ul></li><li><a href="#g:9">Configuring Lenses</a><ul><li><a href="#g:10">Running LensRules</a></li><li><a href="#g:11">LensRules type</a></li><li><a href="#g:12">Predefined LensRules</a></li><li><a href="#g:13">LensRules configuration accessors</a></li><li><a href="#g:14">FieldNamers</a></li></ul></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc empty"> </div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><a href="#v:makeLenses">makeLenses</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a></li><li class="src short"><a href="#v:makeLensesFor">makeLensesFor</a> :: [(<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>)] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a></li><li class="src short"><a href="#v:makeClassy">makeClassy</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a></li><li class="src short"><a href="#v:makeClassyFor">makeClassyFor</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a> -> [(<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>)] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a></li><li class="src short"><a href="#v:makeClassy_">makeClassy_</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a></li><li class="src short"><a href="#v:makeFields">makeFields</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a></li><li class="src short"><a href="#v:makeFieldsNoPrefix">makeFieldsNoPrefix</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a></li><li class="src short"><a href="#v:makePrisms">makePrisms</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a></li><li class="src short"><a href="#v:makeClassyPrisms">makeClassyPrisms</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a></li><li class="src short"><a href="#v:makeWrapped">makeWrapped</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a></li><li class="src short"><a href="#v:declareLenses">declareLenses</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a></li><li class="src short"><a href="#v:declareLensesFor">declareLensesFor</a> :: [(<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>)] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a></li><li class="src short"><a href="#v:declareClassy">declareClassy</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a></li><li class="src short"><a href="#v:declareClassyFor">declareClassyFor</a> :: [(<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>, (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>))] -> [(<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>)] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a></li><li class="src short"><a href="#v:declareFields">declareFields</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a></li><li class="src short"><a href="#v:declarePrisms">declarePrisms</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a></li><li class="src short"><a href="#v:declareWrapped">declareWrapped</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a></li><li class="src short"><a href="#v:makeLensesWith">makeLensesWith</a> :: <a href="Control-Lens-TH.html#t:LensRules">LensRules</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a></li><li class="src short"><a href="#v:declareLensesWith">declareLensesWith</a> :: <a href="Control-Lens-TH.html#t:LensRules">LensRules</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a></li><li class="src short"><span class="keyword">data</span> <a href="#t:LensRules">LensRules</a></li><li class="src short"><a href="#v:lensRules">lensRules</a> :: <a href="Control-Lens-TH.html#t:LensRules">LensRules</a></li><li class="src short"><a href="#v:lensRulesFor">lensRulesFor</a> :: [(<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>)] -> <a href="Control-Lens-TH.html#t:LensRules">LensRules</a></li><li class="src short"><a href="#v:classyRules">classyRules</a> :: <a href="Control-Lens-TH.html#t:LensRules">LensRules</a></li><li class="src short"><a href="#v:classyRules_">classyRules_</a> :: <a href="Control-Lens-TH.html#t:LensRules">LensRules</a></li><li class="src short"><a href="#v:defaultFieldRules">defaultFieldRules</a> :: <a href="Control-Lens-TH.html#t:LensRules">LensRules</a></li><li class="src short"><a href="#v:camelCaseFields">camelCaseFields</a> :: <a href="Control-Lens-TH.html#t:LensRules">LensRules</a></li><li class="src short"><a href="#v:classUnderscoreNoPrefixFields">classUnderscoreNoPrefixFields</a> :: <a href="Control-Lens-TH.html#t:LensRules">LensRules</a></li><li class="src short"><a href="#v:underscoreFields">underscoreFields</a> :: <a href="Control-Lens-TH.html#t:LensRules">LensRules</a></li><li class="src short"><a href="#v:abbreviatedFields">abbreviatedFields</a> :: <a href="Control-Lens-TH.html#t:LensRules">LensRules</a></li><li class="src short"><a href="#v:lensField">lensField</a> :: <a href="Control-Lens-Type.html#t:Lens-39-">Lens'</a> <a href="Control-Lens-TH.html#t:LensRules">LensRules</a> <a href="Control-Lens-TH.html#t:FieldNamer">FieldNamer</a></li><li class="src short"><span class="keyword">type</span> <a href="#t:FieldNamer">FieldNamer</a> = <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> -> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a>] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> -> [<a href="Control-Lens-TH.html#t:DefName">DefName</a>]</li><li class="src short"><span class="keyword">data</span> <a href="#t:DefName">DefName</a><ul class="subs"><li>= <a href="#v:TopName">TopName</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a></li><li>| <a href="#v:MethodName">MethodName</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a></li></ul></li><li class="src short"><a href="#v:lensClass">lensClass</a> :: <a href="Control-Lens-Type.html#t:Lens-39-">Lens'</a> <a href="Control-Lens-TH.html#t:LensRules">LensRules</a> <a href="Control-Lens-TH.html#t:ClassyNamer">ClassyNamer</a></li><li class="src short"><span class="keyword">type</span> <a href="#t:ClassyNamer">ClassyNamer</a> = <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#t:Maybe">Maybe</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a>)</li><li class="src short"><a href="#v:simpleLenses">simpleLenses</a> :: <a href="Control-Lens-Type.html#t:Lens-39-">Lens'</a> <a href="Control-Lens-TH.html#t:LensRules">LensRules</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:createClass">createClass</a> :: <a href="Control-Lens-Type.html#t:Lens-39-">Lens'</a> <a href="Control-Lens-TH.html#t:LensRules">LensRules</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:generateSignatures">generateSignatures</a> :: <a href="Control-Lens-Type.html#t:Lens-39-">Lens'</a> <a href="Control-Lens-TH.html#t:LensRules">LensRules</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:generateUpdateableOptics">generateUpdateableOptics</a> :: <a href="Control-Lens-Type.html#t:Lens-39-">Lens'</a> <a href="Control-Lens-TH.html#t:LensRules">LensRules</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:generateLazyPatterns">generateLazyPatterns</a> :: <a href="Control-Lens-Type.html#t:Lens-39-">Lens'</a> <a href="Control-Lens-TH.html#t:LensRules">LensRules</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:underscoreNoPrefixNamer">underscoreNoPrefixNamer</a> :: <a href="Control-Lens-TH.html#t:FieldNamer">FieldNamer</a></li><li class="src short"><a href="#v:lookingupNamer">lookingupNamer</a> :: [(<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>)] -> <a href="Control-Lens-TH.html#t:FieldNamer">FieldNamer</a></li><li class="src short"><a href="#v:mappingNamer">mappingNamer</a> :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a> -> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>]) -> <a href="Control-Lens-TH.html#t:FieldNamer">FieldNamer</a></li><li class="src short"><a href="#v:camelCaseNamer">camelCaseNamer</a> :: <a href="Control-Lens-TH.html#t:FieldNamer">FieldNamer</a></li><li class="src short"><a href="#v:classUnderscoreNoPrefixNamer">classUnderscoreNoPrefixNamer</a> :: <a href="Control-Lens-TH.html#t:FieldNamer">FieldNamer</a></li><li class="src short"><a href="#v:underscoreNamer">underscoreNamer</a> :: <a href="Control-Lens-TH.html#t:FieldNamer">FieldNamer</a></li><li class="src short"><a href="#v:abbreviatedNamer">abbreviatedNamer</a> :: <a href="Control-Lens-TH.html#t:FieldNamer">FieldNamer</a></li></ul></div><div id="interface"><h1 id="g:1">Constructing Lenses Automatically</h1><h2 id="g:2">Lenses for data fields</h2><div class="top"><p class="src"><a id="v:makeLenses" class="def">makeLenses</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a> <a href="src/Control-Lens-TH.html#makeLenses" class="link">Source</a> <a href="#v:makeLenses" class="selflink">#</a></p><div class="doc"><p>Build lenses (and traversals) with a sensible default configuration.</p><p><em>e.g.</em></p><pre>data FooBar
= Foo { _x, _y :: <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a></code> }
| Bar { _x :: <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a></code> }
<code><a href="Control-Lens-TH.html#v:makeLenses">makeLenses</a></code> ''FooBar
</pre><p>will create</p><pre>x :: <code><a href="Control-Lens-Type.html#t:Lens-39-">Lens'</a></code> FooBar <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a></code>
x f (Foo a b) = (\a' -> Foo a' b) <$> f a
x f (Bar a) = Bar <$> f a
y :: <code><a href="Control-Lens-Type.html#t:Traversal-39-">Traversal'</a></code> FooBar <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a></code>
y f (Foo a b) = (\b' -> Foo a b') <$> f b
y _ c@(Bar _) = pure c
</pre><pre><code><a href="Control-Lens-TH.html#v:makeLenses">makeLenses</a></code> = <code><a href="Control-Lens-TH.html#v:makeLensesWith">makeLensesWith</a></code> <code><a href="Control-Lens-TH.html#v:lensRules">lensRules</a></code>
</pre></div></div><div class="top"><p class="src"><a id="v:makeLensesFor" class="def">makeLensesFor</a> :: [(<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>)] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a> <a href="src/Control-Lens-TH.html#makeLensesFor" class="link">Source</a> <a href="#v:makeLensesFor" class="selflink">#</a></p><div class="doc"><p>Derive lenses and traversals, specifying explicit pairings
of <code>(fieldName, lensName)</code>.</p><p>If you map multiple names to the same label, and it is present in the same
constructor then this will generate a <code><a href="Control-Lens-Type.html#t:Traversal">Traversal</a></code>.</p><p><em>e.g.</em></p><pre><code><a href="Control-Lens-TH.html#v:makeLensesFor">makeLensesFor</a></code> [("_foo", "fooLens"), ("baz", "lbaz")] ''Foo
<code><a href="Control-Lens-TH.html#v:makeLensesFor">makeLensesFor</a></code> [("_barX", "bar"), ("_barY", "bar")] ''Bar
</pre></div></div><div class="top"><p class="src"><a id="v:makeClassy" class="def">makeClassy</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a> <a href="src/Control-Lens-TH.html#makeClassy" class="link">Source</a> <a href="#v:makeClassy" class="selflink">#</a></p><div class="doc"><p>Make lenses and traversals for a type, and create a class when the
type has no arguments.</p><p><em>e.g.</em></p><pre>data Foo = Foo { _fooX, _fooY :: <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a></code> }
<code><a href="Control-Lens-TH.html#v:makeClassy">makeClassy</a></code> ''Foo
</pre><p>will create</p><pre>class HasFoo t where
foo :: <code><a href="Control-Lens-Type.html#t:Lens-39-">Lens'</a></code> t Foo
fooX :: <code><a href="Control-Lens-Type.html#t:Lens-39-">Lens'</a></code> t <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a></code>
fooX = foo . go where go f (Foo x y) = (\x' -> Foo x' y) <$> f x
fooY :: <code><a href="Control-Lens-Type.html#t:Lens-39-">Lens'</a></code> t <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a></code>
fooY = foo . go where go f (Foo x y) = (\y' -> Foo x y') <$> f y
instance HasFoo Foo where
foo = id
</pre><pre><code><a href="Control-Lens-TH.html#v:makeClassy">makeClassy</a></code> = <code><a href="Control-Lens-TH.html#v:makeLensesWith">makeLensesWith</a></code> <code><a href="Control-Lens-TH.html#v:classyRules">classyRules</a></code>
</pre></div></div><div class="top"><p class="src"><a id="v:makeClassyFor" class="def">makeClassyFor</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a> -> [(<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>)] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a> <a href="src/Control-Lens-TH.html#makeClassyFor" class="link">Source</a> <a href="#v:makeClassyFor" class="selflink">#</a></p><div class="doc"><p>Derive lenses and traversals, using a named wrapper class, and
specifying explicit pairings of <code>(fieldName, traversalName)</code>.</p><p>Example usage:</p><pre><code><a href="Control-Lens-TH.html#v:makeClassyFor">makeClassyFor</a></code> "HasFoo" "foo" [("_foo", "fooLens"), ("bar", "lbar")] ''Foo
</pre></div></div><div class="top"><p class="src"><a id="v:makeClassy_" class="def">makeClassy_</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a> <a href="src/Control-Lens-TH.html#makeClassy_" class="link">Source</a> <a href="#v:makeClassy_" class="selflink">#</a></p><div class="doc"><p>Make lenses and traversals for a type, and create a class when the type
has no arguments. Works the same as <code><a href="Control-Lens-TH.html#v:makeClassy">makeClassy</a></code> except that (a) it
expects that record field names do not begin with an underscore, (b) all
record fields are made into lenses, and (c) the resulting lens is prefixed
with an underscore.</p></div></div><div class="top"><p class="src"><a id="v:makeFields" class="def">makeFields</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a> <a href="src/Control-Lens-TH.html#makeFields" class="link">Source</a> <a href="#v:makeFields" class="selflink">#</a></p><div class="doc"><p>Generate overloaded field accessors.</p><p><em>e.g</em></p><pre>data Foo a = Foo { _fooX :: <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a></code>, _fooY :: a }
newtype Bar = Bar { _barX :: <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Char.html#t:Char">Char</a></code> }
makeFields ''Foo
makeFields ''Bar
</pre><p>will create</p><pre>_fooXLens :: Lens' (Foo a) Int
_fooYLens :: Lens (Foo a) (Foo b) a b
class HasX s a | s -> a where
x :: Lens' s a
instance HasX (Foo a) Int where
x = _fooXLens
class HasY s a | s -> a where
y :: Lens' s a
instance HasY (Foo a) a where
y = _fooYLens
_barXLens :: Iso' Bar Char
instance HasX Bar Char where
x = _barXLens
</pre><p>For details, see <code><a href="Control-Lens-TH.html#v:camelCaseFields">camelCaseFields</a></code>.</p><pre>makeFields = <code><a href="Control-Lens-TH.html#v:makeLensesWith">makeLensesWith</a></code> <code><a href="Control-Lens-TH.html#v:defaultFieldRules">defaultFieldRules</a></code>
</pre></div></div><div class="top"><p class="src"><a id="v:makeFieldsNoPrefix" class="def">makeFieldsNoPrefix</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a> <a href="src/Control-Lens-TH.html#makeFieldsNoPrefix" class="link">Source</a> <a href="#v:makeFieldsNoPrefix" class="selflink">#</a></p><div class="doc"><p>Generate overloaded field accessors based on field names which
are only prefixed with an underscore (e.g. <code>_name</code>), not
additionally with the type name (e.g. <code>_fooName</code>).</p><p>This might be the desired behaviour in case the
<code>DuplicateRecordFields</code> language extension is used in order to get
rid of the necessity to prefix each field name with the type name.</p><p>As an example:</p><pre>data Foo a = Foo { _x :: <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a></code>, _y :: a }
newtype Bar = Bar { _x :: <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Char.html#t:Char">Char</a></code> }
makeFieldsNoPrefix ''Foo
makeFieldsNoPrefix ''Bar
</pre><p>will create classes</p><pre>class HasX s a | s -> a where
x :: Lens' s a
class HasY s a | s -> a where
y :: Lens' s a
</pre><p>together with instances</p><pre>instance HasX (Foo a) Int
instance HasY (Foo a) a where
instance HasX Bar Char where
</pre><p>For details, see <code><a href="Control-Lens-TH.html#v:classUnderscoreNoPrefixFields">classUnderscoreNoPrefixFields</a></code>.</p><pre>makeFieldsNoPrefix = <code><a href="Control-Lens-TH.html#v:makeLensesWith">makeLensesWith</a></code> <code><a href="Control-Lens-TH.html#v:classUnderscoreNoPrefixFields">classUnderscoreNoPrefixFields</a></code>
</pre></div></div><h2 id="g:3">Prisms</h2><div class="top"><p class="src"><a id="v:makePrisms" class="def">makePrisms</a> <a href="src/Control-Lens-Internal-PrismTH.html#makePrisms" class="link">Source</a> <a href="#v:makePrisms" class="selflink">#</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a></td><td class="doc"><p>Type constructor name </p></td></tr><tr><td class="src">-> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a></td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Generate a <code>Prism</code> for each constructor of a data type.
Isos generated when possible.
Reviews are created for constructors with existentially
quantified constructors and GADTs.</p><p><em>e.g.</em></p><pre>data FooBarBaz a
= Foo Int
| Bar a
| Baz Int Char
makePrisms ''FooBarBaz
</pre><p>will create</p><pre>_Foo :: Prism' (FooBarBaz a) Int
_Bar :: Prism (FooBarBaz a) (FooBarBaz b) a b
_Baz :: Prism' (FooBarBaz a) (Int, Char)
</pre></div></div><div class="top"><p class="src"><a id="v:makeClassyPrisms" class="def">makeClassyPrisms</a> <a href="src/Control-Lens-Internal-PrismTH.html#makeClassyPrisms" class="link">Source</a> <a href="#v:makeClassyPrisms" class="selflink">#</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a></td><td class="doc"><p>Type constructor name </p></td></tr><tr><td class="src">-> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a></td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Generate a <code>Prism</code> for each constructor of a data type
and combine them into a single class. No Isos are created.
Reviews are created for constructors with existentially
quantified constructors and GADTs.</p><p><em>e.g.</em></p><pre>data FooBarBaz a
= Foo Int
| Bar a
| Baz Int Char
makeClassyPrisms ''FooBarBaz
</pre><p>will create</p><pre>class AsFooBarBaz s a | s -> a where
_FooBarBaz :: Prism' s (FooBarBaz a)
_Foo :: Prism' s Int
_Bar :: Prism' s a
_Baz :: Prism' s (Int,Char)
_Foo = _FooBarBaz . _Foo
_Bar = _FooBarBaz . _Bar
_Baz = _FooBarBaz . _Baz
instance AsFooBarBaz (FooBarBaz a) a
</pre><p>Generate an <a href="As.html">As</a> class of prisms. Names are selected by prefixing the constructor
name with an underscore. Constructors with multiple fields will
construct Prisms to tuples of those fields.</p></div></div><h2 id="g:4">Wrapped</h2><div class="top"><p class="src"><a id="v:makeWrapped" class="def">makeWrapped</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a> <a href="src/Control-Lens-TH.html#makeWrapped" class="link">Source</a> <a href="#v:makeWrapped" class="selflink">#</a></p><div class="doc"><p>Build <code>Wrapped</code> instance for a given newtype</p></div></div><h1 id="g:5">Constructing Lenses Given a Declaration Quote</h1><h2 id="g:6">Lenses for data fields</h2><div class="top"><p class="src"><a id="v:declareLenses" class="def">declareLenses</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a> <a href="src/Control-Lens-TH.html#declareLenses" class="link">Source</a> <a href="#v:declareLenses" class="selflink">#</a></p><div class="doc"><p>Make lenses for all records in the given declaration quote. All record
syntax in the input will be stripped off.</p><p><em>e.g.</em></p><pre>declareLenses [d|
data Foo = Foo { fooX, fooY :: <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a></code> }
deriving <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Text-Show.html#t:Show">Show</a></code>
|]
</pre><p>will create</p><pre>data Foo = Foo <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a></code> <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a></code> deriving <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Text-Show.html#t:Show">Show</a></code>
fooX, fooY :: <code><a href="Control-Lens-Type.html#t:Lens-39-">Lens'</a></code> Foo Int
</pre></div></div><div class="top"><p class="src"><a id="v:declareLensesFor" class="def">declareLensesFor</a> :: [(<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>)] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a> <a href="src/Control-Lens-TH.html#declareLensesFor" class="link">Source</a> <a href="#v:declareLensesFor" class="selflink">#</a></p><div class="doc"><p>Similar to <code><a href="Control-Lens-TH.html#v:makeLensesFor">makeLensesFor</a></code>, but takes a declaration quote.</p></div></div><div class="top"><p class="src"><a id="v:declareClassy" class="def">declareClassy</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a> <a href="src/Control-Lens-TH.html#declareClassy" class="link">Source</a> <a href="#v:declareClassy" class="selflink">#</a></p><div class="doc"><p>For each record in the declaration quote, make lenses and traversals for
it, and create a class when the type has no arguments. All record syntax
in the input will be stripped off.</p><p><em>e.g.</em></p><pre>declareClassy [d|
data Foo = Foo { fooX, fooY :: <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a></code> }
deriving <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Text-Show.html#t:Show">Show</a></code>
|]
</pre><p>will create</p><pre>data Foo = Foo <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a></code> <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a></code> deriving <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Text-Show.html#t:Show">Show</a></code>
class HasFoo t where
foo :: <code><a href="Control-Lens-Type.html#t:Lens-39-">Lens'</a></code> t Foo
instance HasFoo Foo where foo = <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Function.html#v:id">id</a></code>
fooX, fooY :: HasFoo t => <code><a href="Control-Lens-Type.html#t:Lens-39-">Lens'</a></code> t <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a></code>
</pre></div></div><div class="top"><p class="src"><a id="v:declareClassyFor" class="def">declareClassyFor</a> :: [(<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>, (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>))] -> [(<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>)] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a> <a href="src/Control-Lens-TH.html#declareClassyFor" class="link">Source</a> <a href="#v:declareClassyFor" class="selflink">#</a></p><div class="doc"><p>Similar to <code><a href="Control-Lens-TH.html#v:makeClassyFor">makeClassyFor</a></code>, but takes a declaration quote.</p></div></div><div class="top"><p class="src"><a id="v:declareFields" class="def">declareFields</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a> <a href="src/Control-Lens-TH.html#declareFields" class="link">Source</a> <a href="#v:declareFields" class="selflink">#</a></p><div class="doc"><pre> declareFields = <code><a href="Control-Lens-TH.html#v:declareLensesWith">declareLensesWith</a></code> <code><a href="Control-Lens-TH.html#v:defaultFieldRules">defaultFieldRules</a></code></pre></div></div><h2 id="g:7">Prisms</h2><div class="top"><p class="src"><a id="v:declarePrisms" class="def">declarePrisms</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a> <a href="src/Control-Lens-TH.html#declarePrisms" class="link">Source</a> <a href="#v:declarePrisms" class="selflink">#</a></p><div class="doc"><p>Generate a <code><a href="Control-Lens-Type.html#v:Prism">Prism</a></code> for each constructor of each data type.</p><p><em>e.g.</em></p><pre>declarePrisms [d|
data Exp = Lit Int | Var String | Lambda{ bound::String, body::Exp }
|]
</pre><p>will create</p><pre>data Exp = Lit Int | Var String | Lambda { bound::String, body::Exp }
_Lit :: <code>Prism'</code> Exp Int
_Var :: <code>Prism'</code> Exp String
_Lambda :: <code>Prism'</code> Exp (String, Exp)
</pre></div></div><h2 id="g:8">Wrapped</h2><div class="top"><p class="src"><a id="v:declareWrapped" class="def">declareWrapped</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a> <a href="src/Control-Lens-TH.html#declareWrapped" class="link">Source</a> <a href="#v:declareWrapped" class="selflink">#</a></p><div class="doc"><p>Build <code><a href="Control-Lens-Wrapped.html#v:Wrapped">Wrapped</a></code> instance for each newtype.</p></div></div><h1 id="g:9">Configuring Lenses</h1><h2 id="g:10">Running LensRules</h2><div class="top"><p class="src"><a id="v:makeLensesWith" class="def">makeLensesWith</a> :: <a href="Control-Lens-TH.html#t:LensRules">LensRules</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a> <a href="src/Control-Lens-TH.html#makeLensesWith" class="link">Source</a> <a href="#v:makeLensesWith" class="selflink">#</a></p><div class="doc"><p>Build lenses with a custom configuration.</p></div></div><div class="top"><p class="src"><a id="v:declareLensesWith" class="def">declareLensesWith</a> :: <a href="Control-Lens-TH.html#t:LensRules">LensRules</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Lib.html#t:DecsQ">DecsQ</a> <a href="src/Control-Lens-TH.html#declareLensesWith" class="link">Source</a> <a href="#v:declareLensesWith" class="selflink">#</a></p><div class="doc"><p>Declare lenses for each records in the given declarations, using the
specified <code><a href="Control-Lens-TH.html#t:LensRules">LensRules</a></code>. Any record syntax in the input will be stripped
off.</p></div></div><h2 id="g:11">LensRules type</h2><div class="top"><p class="src"><span class="keyword">data</span> <a id="t:LensRules" class="def">LensRules</a> <a href="src/Control-Lens-Internal-FieldTH.html#LensRules" class="link">Source</a> <a href="#t:LensRules" class="selflink">#</a></p><div class="doc"><p>Rules to construct lenses for data fields.</p></div></div><h2 id="g:12">Predefined LensRules</h2><div class="top"><p class="src"><a id="v:lensRules" class="def">lensRules</a> :: <a href="Control-Lens-TH.html#t:LensRules">LensRules</a> <a href="src/Control-Lens-TH.html#lensRules" class="link">Source</a> <a href="#v:lensRules" class="selflink">#</a></p><div class="doc"><p>Rules for making fairly simple partial lenses, ignoring the special cases
for isomorphisms and traversals, and not making any classes.
It uses <code><a href="Control-Lens-TH.html#v:underscoreNoPrefixNamer">underscoreNoPrefixNamer</a></code>.</p></div></div><div class="top"><p class="src"><a id="v:lensRulesFor" class="def">lensRulesFor</a> <a href="src/Control-Lens-TH.html#lensRulesFor" class="link">Source</a> <a href="#v:lensRulesFor" class="selflink">#</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: [(<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>)]</td><td class="doc"><dl><dt>(Field Name, Definition Name)</dt><dd></dd></dl></td></tr><tr><td class="src">-> <a href="Control-Lens-TH.html#t:LensRules">LensRules</a></td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Construct a <code><a href="Control-Lens-TH.html#t:LensRules">LensRules</a></code> value for generating top-level definitions
using the given map from field names to definition names.</p></div></div><div class="top"><p class="src"><a id="v:classyRules" class="def">classyRules</a> :: <a href="Control-Lens-TH.html#t:LensRules">LensRules</a> <a href="src/Control-Lens-TH.html#classyRules" class="link">Source</a> <a href="#v:classyRules" class="selflink">#</a></p><div class="doc"><p>Rules for making lenses and traversals that precompose another <code><a href="Control-Lens-Type.html#t:Lens">Lens</a></code>.</p></div></div><div class="top"><p class="src"><a id="v:classyRules_" class="def">classyRules_</a> :: <a href="Control-Lens-TH.html#t:LensRules">LensRules</a> <a href="src/Control-Lens-TH.html#classyRules_" class="link">Source</a> <a href="#v:classyRules_" class="selflink">#</a></p><div class="doc"><p>A <code><a href="Control-Lens-TH.html#t:LensRules">LensRules</a></code> used by <code><a href="Control-Lens-TH.html#v:makeClassy_">makeClassy_</a></code>.</p></div></div><div class="top"><p class="src"><a id="v:defaultFieldRules" class="def">defaultFieldRules</a> :: <a href="Control-Lens-TH.html#t:LensRules">LensRules</a> <a href="src/Control-Lens-TH.html#defaultFieldRules" class="link">Source</a> <a href="#v:defaultFieldRules" class="selflink">#</a></p></div><div class="top"><p class="src"><a id="v:camelCaseFields" class="def">camelCaseFields</a> :: <a href="Control-Lens-TH.html#t:LensRules">LensRules</a> <a href="src/Control-Lens-TH.html#camelCaseFields" class="link">Source</a> <a href="#v:camelCaseFields" class="selflink">#</a></p><div class="doc"><p>Field rules for fields in the form <code> prefixFieldname or _prefixFieldname </code>
If you want all fields to be lensed, then there is no reason to use an <code>_</code> before the prefix.
If any of the record fields leads with an <code>_</code> then it is assume a field without an <code>_</code> should not have a lens created.</p><p><strong>Note</strong>: The <code>prefix</code> must be the same as the typename (with the first
letter lowercased). This is a change from lens versions before lens 4.5.
If you want the old behaviour, use <code><a href="Control-Lens-TH.html#v:makeLensesWith">makeLensesWith</a></code> <code><a href="Control-Lens-TH.html#v:abbreviatedFields">abbreviatedFields</a></code></p></div></div><div class="top"><p class="src"><a id="v:classUnderscoreNoPrefixFields" class="def">classUnderscoreNoPrefixFields</a> :: <a href="Control-Lens-TH.html#t:LensRules">LensRules</a> <a href="src/Control-Lens-TH.html#classUnderscoreNoPrefixFields" class="link">Source</a> <a href="#v:classUnderscoreNoPrefixFields" class="selflink">#</a></p><div class="doc"><p>Field rules for fields in the form <code> _fieldname </code> (the leading
underscore is mandatory).</p><p><strong>Note</strong>: The primary difference to <code><a href="Control-Lens-TH.html#v:camelCaseFields">camelCaseFields</a></code> is that for
<code>classUnderscoreNoPrefixFields</code> the field names are not expected to
be prefixed with the type name. This might be the desired behaviour
when the <code>DuplicateRecordFields</code> extension is enabled.</p></div></div><div class="top"><p class="src"><a id="v:underscoreFields" class="def">underscoreFields</a> :: <a href="Control-Lens-TH.html#t:LensRules">LensRules</a> <a href="src/Control-Lens-TH.html#underscoreFields" class="link">Source</a> <a href="#v:underscoreFields" class="selflink">#</a></p><div class="doc"><p>Field rules for fields in the form <code> _prefix_fieldname </code></p></div></div><div class="top"><p class="src"><a id="v:abbreviatedFields" class="def">abbreviatedFields</a> :: <a href="Control-Lens-TH.html#t:LensRules">LensRules</a> <a href="src/Control-Lens-TH.html#abbreviatedFields" class="link">Source</a> <a href="#v:abbreviatedFields" class="selflink">#</a></p><div class="doc"><p>Field rules fields in the form <code> prefixFieldname or _prefixFieldname </code>
If you want all fields to be lensed, then there is no reason to use an <code>_</code> before the prefix.
If any of the record fields leads with an <code>_</code> then it is assume a field without an <code>_</code> should not have a lens created.</p><p>Note that <code>prefix</code> may be any string of characters that are not uppercase
letters. (In particular, it may be arbitrary string of lowercase letters
and numbers) This is the behavior that <code><a href="Control-Lens-TH.html#v:defaultFieldRules">defaultFieldRules</a></code> had in lens
4.4 and earlier.</p></div></div><h2 id="g:13">LensRules configuration accessors</h2><div class="top"><p class="src"><a id="v:lensField" class="def">lensField</a> :: <a href="Control-Lens-Type.html#t:Lens-39-">Lens'</a> <a href="Control-Lens-TH.html#t:LensRules">LensRules</a> <a href="Control-Lens-TH.html#t:FieldNamer">FieldNamer</a> <a href="src/Control-Lens-TH.html#lensField" class="link">Source</a> <a href="#v:lensField" class="selflink">#</a></p><div class="doc"><p><code><a href="Control-Lens-Type.html#t:Lens-39-">Lens'</a></code> to access the convention for naming fields in our <code><a href="Control-Lens-TH.html#t:LensRules">LensRules</a></code>.</p></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a id="t:FieldNamer" class="def">FieldNamer</a> <a href="src/Control-Lens-Internal-FieldTH.html#FieldNamer" class="link">Source</a> <a href="#t:FieldNamer" class="selflink">#</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src"> = <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a></td><td class="doc"><p>Name of the data type that lenses are being generated for.</p></td></tr><tr><td class="src">-> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a>]</td><td class="doc"><p>Names of all fields (including the field being named) in the data type.</p></td></tr><tr><td class="src">-> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a></td><td class="doc"><p>Name of the field being named.</p></td></tr><tr><td class="src">-> [<a href="Control-Lens-TH.html#t:DefName">DefName</a>]</td><td class="doc"><p>Name(s) of the lens functions. If empty, no lens is created for that field.</p></td></tr></table></div><div class="doc"><p>The rule to create function names of lenses for data fields.</p><p>Although it's sometimes useful, you won't need the first two
arguments most of the time.</p></div></div><div class="top"><p class="src"><span class="keyword">data</span> <a id="t:DefName" class="def">DefName</a> <a href="src/Control-Lens-Internal-FieldTH.html#DefName" class="link">Source</a> <a href="#t:DefName" class="selflink">#</a></p><div class="doc"><p>Name to give to generated field optics.</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a id="v:TopName" class="def">TopName</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a></td><td class="doc"><p>Simple top-level definiton name</p></td></tr><tr><td class="src"><a id="v:MethodName" class="def">MethodName</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a></td><td class="doc"><p>makeFields-style class name and method name</p></td></tr></table></div><div class="subs instances"><p id="control.i:DefName" class="caption collapser" onclick="toggleSection('i:DefName')">Instances</p><div id="section.i:DefName" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:DefName:Eq:1" class="instance expander" onclick="toggleSection('i:id:DefName:Eq:1')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Eq.html#t:Eq">Eq</a> <a href="Control-Lens-TH.html#t:DefName">DefName</a></span> <a href="src/Control-Lens-Internal-FieldTH.html#line-600" class="link">Source</a> <a href="#t:DefName" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:DefName:Eq:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-61--61-">(==)</a> :: <a href="Control-Lens-TH.html#t:DefName">DefName</a> -> <a href="Control-Lens-TH.html#t:DefName">DefName</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a> <a href="#v:-61--61-" class="selflink">#</a></p><p class="src"><a href="#v:-47--61-">(/=)</a> :: <a href="Control-Lens-TH.html#t:DefName">DefName</a> -> <a href="Control-Lens-TH.html#t:DefName">DefName</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a> <a href="#v:-47--61-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:DefName:Ord:2" class="instance expander" onclick="toggleSection('i:id:DefName:Ord:2')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Ord.html#t:Ord">Ord</a> <a href="Control-Lens-TH.html#t:DefName">DefName</a></span> <a href="src/Control-Lens-Internal-FieldTH.html#line-600" class="link">Source</a> <a href="#t:DefName" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:DefName:Ord:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:compare">compare</a> :: <a href="Control-Lens-TH.html#t:DefName">DefName</a> -> <a href="Control-Lens-TH.html#t:DefName">DefName</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Ord.html#t:Ordering">Ordering</a> <a href="#v:compare" class="selflink">#</a></p><p class="src"><a href="#v:-60-">(<)</a> :: <a href="Control-Lens-TH.html#t:DefName">DefName</a> -> <a href="Control-Lens-TH.html#t:DefName">DefName</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a> <a href="#v:-60-" class="selflink">#</a></p><p class="src"><a href="#v:-60--61-">(<=)</a> :: <a href="Control-Lens-TH.html#t:DefName">DefName</a> -> <a href="Control-Lens-TH.html#t:DefName">DefName</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a> <a href="#v:-60--61-" class="selflink">#</a></p><p class="src"><a href="#v:-62-">(>)</a> :: <a href="Control-Lens-TH.html#t:DefName">DefName</a> -> <a href="Control-Lens-TH.html#t:DefName">DefName</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a> <a href="#v:-62-" class="selflink">#</a></p><p class="src"><a href="#v:-62--61-">(>=)</a> :: <a href="Control-Lens-TH.html#t:DefName">DefName</a> -> <a href="Control-Lens-TH.html#t:DefName">DefName</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a> <a href="#v:-62--61-" class="selflink">#</a></p><p class="src"><a href="#v:max">max</a> :: <a href="Control-Lens-TH.html#t:DefName">DefName</a> -> <a href="Control-Lens-TH.html#t:DefName">DefName</a> -> <a href="Control-Lens-TH.html#t:DefName">DefName</a> <a href="#v:max" class="selflink">#</a></p><p class="src"><a href="#v:min">min</a> :: <a href="Control-Lens-TH.html#t:DefName">DefName</a> -> <a href="Control-Lens-TH.html#t:DefName">DefName</a> -> <a href="Control-Lens-TH.html#t:DefName">DefName</a> <a href="#v:min" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:DefName:Show:3" class="instance expander" onclick="toggleSection('i:id:DefName:Show:3')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Text-Show.html#t:Show">Show</a> <a href="Control-Lens-TH.html#t:DefName">DefName</a></span> <a href="src/Control-Lens-Internal-FieldTH.html#line-600" class="link">Source</a> <a href="#t:DefName" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:DefName:Show:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:showsPrec">showsPrec</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a> -> <a href="Control-Lens-TH.html#t:DefName">DefName</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showsPrec" class="selflink">#</a></p><p class="src"><a href="#v:show">show</a> :: <a href="Control-Lens-TH.html#t:DefName">DefName</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a> <a href="#v:show" class="selflink">#</a></p><p class="src"><a href="#v:showList">showList</a> :: [<a href="Control-Lens-TH.html#t:DefName">DefName</a>] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showList" class="selflink">#</a></p></div></div></td></tr></table></div></div></div><div class="top"><p class="src"><a id="v:lensClass" class="def">lensClass</a> :: <a href="Control-Lens-Type.html#t:Lens-39-">Lens'</a> <a href="Control-Lens-TH.html#t:LensRules">LensRules</a> <a href="Control-Lens-TH.html#t:ClassyNamer">ClassyNamer</a> <a href="src/Control-Lens-TH.html#lensClass" class="link">Source</a> <a href="#v:lensClass" class="selflink">#</a></p><div class="doc"><p><code><a href="Control-Lens-Type.html#t:Lens-39-">Lens'</a></code> to access the option for naming "classy" lenses.</p></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a id="t:ClassyNamer" class="def">ClassyNamer</a> <a href="src/Control-Lens-Internal-FieldTH.html#ClassyNamer" class="link">Source</a> <a href="#t:ClassyNamer" class="selflink">#</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src"> = <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a></td><td class="doc"><p>Name of the data type that lenses are being generated for.</p></td></tr><tr><td class="src">-> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#t:Maybe">Maybe</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a>)</td><td class="doc"><p>Names of the class and the main method it generates, respectively.</p></td></tr></table></div><div class="doc"><p>The optional rule to create a class and method around a
monomorphic data type. If this naming convention is provided, it
generates a "classy" lens.</p></div></div><div class="top"><p class="src"><a id="v:simpleLenses" class="def">simpleLenses</a> :: <a href="Control-Lens-Type.html#t:Lens-39-">Lens'</a> <a href="Control-Lens-TH.html#t:LensRules">LensRules</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a> <a href="src/Control-Lens-TH.html#simpleLenses" class="link">Source</a> <a href="#v:simpleLenses" class="selflink">#</a></p><div class="doc"><p>Generate "simple" optics even when type-changing optics are possible.
(e.g. <code><a href="Control-Lens-Type.html#t:Lens-39-">Lens'</a></code> instead of <code><a href="Control-Lens-Type.html#t:Lens">Lens</a></code>)</p></div></div><div class="top"><p class="src"><a id="v:createClass" class="def">createClass</a> :: <a href="Control-Lens-Type.html#t:Lens-39-">Lens'</a> <a href="Control-Lens-TH.html#t:LensRules">LensRules</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a> <a href="src/Control-Lens-TH.html#createClass" class="link">Source</a> <a href="#v:createClass" class="selflink">#</a></p><div class="doc"><p>Create the class if the constructor is <code><a href="Control-Lens-Type.html#v:Simple">Simple</a></code> and the
<code><a href="Control-Lens-TH.html#v:lensClass">lensClass</a></code> rule matches.</p></div></div><div class="top"><p class="src"><a id="v:generateSignatures" class="def">generateSignatures</a> :: <a href="Control-Lens-Type.html#t:Lens-39-">Lens'</a> <a href="Control-Lens-TH.html#t:LensRules">LensRules</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a> <a href="src/Control-Lens-TH.html#generateSignatures" class="link">Source</a> <a href="#v:generateSignatures" class="selflink">#</a></p><div class="doc"><p>Indicate whether or not to supply the signatures for the generated
lenses.</p><p>Disabling this can be useful if you want to provide a more restricted type
signature or if you want to supply hand-written haddocks.</p></div></div><div class="top"><p class="src"><a id="v:generateUpdateableOptics" class="def">generateUpdateableOptics</a> :: <a href="Control-Lens-Type.html#t:Lens-39-">Lens'</a> <a href="Control-Lens-TH.html#t:LensRules">LensRules</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a> <a href="src/Control-Lens-TH.html#generateUpdateableOptics" class="link">Source</a> <a href="#v:generateUpdateableOptics" class="selflink">#</a></p><div class="doc"><p>Generate "updateable" optics when <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#v:True">True</a></code>. When <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#v:False">False</a></code>, <code><a href="Control-Lens-Type.html#t:Fold">Fold</a></code>s will be
generated instead of <code><a href="Control-Lens-Type.html#t:Traversal">Traversal</a></code>s and <code><a href="Control-Lens-Type.html#t:Getter">Getter</a></code>s will be generated instead
of <code><a href="Control-Lens-Type.html#t:Lens">Lens</a></code>es. This mode is intended to be used for types with invariants
which must be maintained by "smart" constructors.</p></div></div><div class="top"><p class="src"><a id="v:generateLazyPatterns" class="def">generateLazyPatterns</a> :: <a href="Control-Lens-Type.html#t:Lens-39-">Lens'</a> <a href="Control-Lens-TH.html#t:LensRules">LensRules</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a> <a href="src/Control-Lens-TH.html#generateLazyPatterns" class="link">Source</a> <a href="#v:generateLazyPatterns" class="selflink">#</a></p><div class="doc"><p>Generate optics using lazy pattern matches. This can
allow fields of an undefined value to be initialized with lenses:</p><pre>data Foo = Foo {_x :: Int, _y :: Bool}
deriving Show
<code><a href="Control-Lens-TH.html#v:makeLensesWith">makeLensesWith</a></code> (<code><a href="Control-Lens-TH.html#v:lensRules">lensRules</a></code> & <code><a href="Control-Lens-TH.html#v:generateLazyPatterns">generateLazyPatterns</a></code> .~ True) ''Foo
</pre><pre>> undefined & x .~ 8 & y .~ True
Foo {_x = 8, _y = True}
</pre><p>The downside of this flag is that it can lead to space-leaks and
code-size/compile-time increases when generated for large records. By
default this flag is turned off, and strict optics are generated.</p><p>When using lazy optics the strict optic can be recovered by composing
with <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Prelude.html#v:-36--33-">$!</a></code>:</p><pre>strictOptic = ($!) . lazyOptic
</pre></div></div><h2 id="g:14">FieldNamers</h2><div class="top"><p class="src"><a id="v:underscoreNoPrefixNamer" class="def">underscoreNoPrefixNamer</a> :: <a href="Control-Lens-TH.html#t:FieldNamer">FieldNamer</a> <a href="src/Control-Lens-TH.html#underscoreNoPrefixNamer" class="link">Source</a> <a href="#v:underscoreNoPrefixNamer" class="selflink">#</a></p><div class="doc"><p>A <code><a href="Control-Lens-TH.html#t:FieldNamer">FieldNamer</a></code> that strips the _ off of the field name,
lowercases the name, and skips the field if it doesn't start with
an '_'.</p></div></div><div class="top"><p class="src"><a id="v:lookingupNamer" class="def">lookingupNamer</a> :: [(<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>)] -> <a href="Control-Lens-TH.html#t:FieldNamer">FieldNamer</a> <a href="src/Control-Lens-TH.html#lookingupNamer" class="link">Source</a> <a href="#v:lookingupNamer" class="selflink">#</a></p><div class="doc"><p>Create a <code><a href="Control-Lens-TH.html#t:FieldNamer">FieldNamer</a></code> from explicit pairings of <code>(fieldName, lensName)</code>.</p></div></div><div class="top"><p class="src"><a id="v:mappingNamer" class="def">mappingNamer</a> <a href="src/Control-Lens-TH.html#mappingNamer" class="link">Source</a> <a href="#v:mappingNamer" class="selflink">#</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a> -> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>])</td><td class="doc"><p>A function that maps a <code>fieldName</code> to <code>lensName</code>s.</p></td></tr><tr><td class="src">-> <a href="Control-Lens-TH.html#t:FieldNamer">FieldNamer</a></td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Create a <code><a href="Control-Lens-TH.html#t:FieldNamer">FieldNamer</a></code> from a mapping function. If the function
returns <code>[]</code>, it creates no lens for the field.</p></div></div><div class="top"><p class="src"><a id="v:camelCaseNamer" class="def">camelCaseNamer</a> :: <a href="Control-Lens-TH.html#t:FieldNamer">FieldNamer</a> <a href="src/Control-Lens-TH.html#camelCaseNamer" class="link">Source</a> <a href="#v:camelCaseNamer" class="selflink">#</a></p><div class="doc"><p>A <code><a href="Control-Lens-TH.html#t:FieldNamer">FieldNamer</a></code> for <code><a href="Control-Lens-TH.html#v:camelCaseFields">camelCaseFields</a></code>.</p></div></div><div class="top"><p class="src"><a id="v:classUnderscoreNoPrefixNamer" class="def">classUnderscoreNoPrefixNamer</a> :: <a href="Control-Lens-TH.html#t:FieldNamer">FieldNamer</a> <a href="src/Control-Lens-TH.html#classUnderscoreNoPrefixNamer" class="link">Source</a> <a href="#v:classUnderscoreNoPrefixNamer" class="selflink">#</a></p><div class="doc"><p>A <code><a href="Control-Lens-TH.html#t:FieldNamer">FieldNamer</a></code> for <code><a href="Control-Lens-TH.html#v:classUnderscoreNoPrefixFields">classUnderscoreNoPrefixFields</a></code>.</p></div></div><div class="top"><p class="src"><a id="v:underscoreNamer" class="def">underscoreNamer</a> :: <a href="Control-Lens-TH.html#t:FieldNamer">FieldNamer</a> <a href="src/Control-Lens-TH.html#underscoreNamer" class="link">Source</a> <a href="#v:underscoreNamer" class="selflink">#</a></p><div class="doc"><p>A <code><a href="Control-Lens-TH.html#t:FieldNamer">FieldNamer</a></code> for <code><a href="Control-Lens-TH.html#v:underscoreFields">underscoreFields</a></code>.</p></div></div><div class="top"><p class="src"><a id="v:abbreviatedNamer" class="def">abbreviatedNamer</a> :: <a href="Control-Lens-TH.html#t:FieldNamer">FieldNamer</a> <a href="src/Control-Lens-TH.html#abbreviatedNamer" class="link">Source</a> <a href="#v:abbreviatedNamer" class="selflink">#</a></p><div class="doc"><p>A <code><a href="Control-Lens-TH.html#t:FieldNamer">FieldNamer</a></code> for <code><a href="Control-Lens-TH.html#v:abbreviatedFields">abbreviatedFields</a></code>.</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.3</p></div></body></html>
|