h&@>3      !"#$%&'()*+,-./0127(C) 2013-2016 Eric Mertens, Edward Kmett; 2018 Monadfix BSD-style (see the file LICENSE)Safe$  microlens-thProvides for the extraction of free type variables, and alpha renaming. microlens-thHas a 3 microlens-thExtract (or modify) the 3 of something microlens-th/Generate many new names from a given base name. microlens-thGenerate an INLINE pragma. microlens-th&Apply arguments to a type constructor.  microlens-thTemplate Haskell wants type variables declared in a forall, so we find all free type variables in a given type and declare them.  microlens-thThis function works like   except that it takes a list of variables to exclude from quantification.  microlens-th Convert a 4 into its corresponding 5.  microlens-th6Peel off a kind signature from a Type (if it has one). microlens-thOn template-haskell-2.11.0.0 or later, if a 6 or 7 has multiple 3s, the leftmost 3 will be chosen. microlens-th base name  microlens-thcount    (C) 2013-2016 Eric Mertens, Edward Kmett, Artyom Kazak; 2018 Monadfix BSD-style (see the file LICENSE) Trustworthy> microlens-th*Name to give to a generated lens (used in (). microlens-thSimple top-level definiton name microlens-th"!-style class name and method name microlens-thRules used to generate lenses. The fields are intentionally not exported; to create your own rules, see lenses in the @Configuring lens rules@ section. You'd have to customise one of the existing rulesets; for an example of doing that, see !. microlens-th-Generate lenses for a data type or a newtype.5To use it, you have to enable Template Haskell first: !{-# LANGUAGE TemplateHaskell #-} .Then, after declaring the datatype (let's say Foo), add makeLenses ''Foo on a separate line (if you do it before the type is declared, you'll get a @not in scope@ error @ see the section at the top of this page): .data Foo = Foo { _x :: Int, _y :: Bool }  ''Foo This would generate the following lenses, which can be used to access the fields of Foo: x :: 8* Foo Int x f foo = (\x' -> foo {_x = x'}) 9 f (_x foo) y :: 8+ Foo Bool y f foo = (\y' -> foo {_y = y'}) 9 f (_y foo) (If you don't want a lens to be generated for some field, don't prefix it with @_@.)If you want to create lenses for many types, you can do it all in one place like this (of course, instead you just can use 6 several times if you feel it would be more readable): /data Foo = ... data Bar = ... data Quux = ... : 9 ;  [''Foo, ''Bar, ''Quux] When the data type has type parameters, it's possible for a lens to do a polymorphic update @ i.e. change the type of the thing along with changing the type of the field. For instance, with this type -data Foo a = Foo { _x :: a, _y :: Bool } (the following lenses would be generated: x :: < (Foo a) (Foo b) a b y :: 8 (Foo a) Bool However, when there are several fields using the same type parameter, type-changing updates are no longer possible: *data Foo a = Foo { _x :: a, _y :: a }  generates x :: 8 (Foo a) a y :: 8 (Foo a) a Finally, when the type has several constructors, some of fields may not be always present @ for those, a =5 is generated instead. For instance, in this example y can be present or absent: data FooBar = Foo { _x :: Int, _y :: Bool } | Bar { _x :: Int } /and the following accessors would be generated: x :: 8 FooBar Int y :: > FooBar Bool  So, to get _y, you'd have to either use (?%) if you're not sure it's there, or (@) if you're absolutely sure (and if you're wrong, you'll get an exception). Setting and updating _y can be done as usual.  microlens-thLike 0, but lets you choose your own names for lenses: *data Foo = Foo {foo :: Int, bar :: Bool}  - [("foo", "fooLens"), ("bar", "_bar")] ''Foo would create lenses called fooLens and _bar. This is useful, for instance, when you don't want to prefix your fields with underscores and want to prefix lenses with underscores instead.If you give the same name to different fields, it will generate a = instead: -data Foo = Foo {slot1, slot2, slot3 :: Int}   [("slot1", "slots"), ("slot2", "slots"), ("slot3", "slots")] ''Foo would generate  slots :: > Foo Int slots f foo = Foo 9! f (slot1 foo) A! f (slot2 foo) A f (slot3 foo) ! microlens-th'Generate lenses with custom parameters.To see what exactly you can customise, look at the @Configuring lens rules@ section. Usually you would build upon the +! configuration, which is used by :  = ! + Here's an example of generating lenses that would use lazy patterns:  data Foo = Foo {_x, _y :: Int} ! (+ B ' C True) ''Foo When there are several modifications to the rules, the code looks nicer when you use D: D ! ''Foo $ + B ' C True B % C False " microlens-thGenerate overloaded lenses.This lets you deal with several data types having same fields. For instance, let's say you have Foo and Bar, and both have a field named x. To avoid those fields clashing, you would have to use prefixes: data Foo a = Foo { fooX :: Int, fooY :: a } data Bar = Bar { barX :: Char } However, if you use " on both Foo and Bar& now, it would generate lenses called x and y @ and x would be able to access both fooX and barX! This is done by generating a separate class for each field, and making relevant types instances of that class: %class HasX s a | s -> a where x :: 8- s a instance HasX (Foo a) Int where x :: 8< (Foo a) Int x = ... instance HasX Bar Char where x :: 8; Bar Char x = ... class HasY s a | s -> a where y :: 8+ s a instance HasY (Foo a) a where y :: 8 (Foo a) a y = ... (There's a minor drawback, though: you can't perform type-changing updates with these lenses.)If you only want to make lenses for some fields, you can prefix them with underscores @ the rest would be untouched. If no fields are prefixed with underscores, lenses would be created for all fields.The prefix must be the same as the name of the name of the data type (not8 the constructor). If you don't like this behavior, use ! .6 @ it allows any prefix (and even different prefixes).If you want to use " on types declared in different modules, you can do it, but then you would have to export the Has*# classes from one of the modules @ " creates a class if it's not in scope yet, so the class must be in scope or else there would be duplicate classes and you would get an @Ambiguous occurrence@ error. Finally, " is implemented as ! -, so you can build on -& if you want to customise behavior of ".# microlens-thGenerate overloaded lenses without ad-hoc classes; useful when there's a collection of fields that you want to make common for several types.Like ", each lens is a member of a class. However, the classes are per-type and not per-field. Let's take the following type: =data Person = Person { _name :: String, _age :: Double } #. would generate a single class with 3 methods: class HasPerson c where person :: Lens' c Person age :: Lens' c Double age = person.age name :: Lens' c String name = person.name And an instance: instance HasPerson Person where person = id name = ... age = ... So, you can use name and age to refer to the _name and _age- fields, as usual. However, the extra lens @ person @ allows you to do a kind of subtyping. Let's say that there's a type called Worker and every worker has the same fields that a person has, but also a job. If you were using ", you'd do the following: data Worker = Worker { _workerName :: String, _workerAge :: Double, _workerJob :: String } However, with # you can say @every worker is a person@ in a more principled way: data Worker = Worker { _workerPerson :: Person, _job :: String } makeClassy ''Worker instance HasPerson Worker where person = workerPerson Now you can use age and name to access name/age of a Worker, but you also can use person to @downgrade@ a Worker to a Person (and e.g. apply some Person-specific function to it).Unlike ", # doesn't make use of prefixes.  _workerPerson" could've just as well been named _foobar.# is implemented as ! /, so you can build on /& if you want to customise behavior of #.$ microlens-thGenerate simple (monomorphic) lenses even when type-changing lenses are possible @ i.e. 8 instead of < and > instead of =. Just in case, here's an example of a situation when type-changing lenses would be normally generated: data Foo a = Foo { _foo :: a } Generated lens: foo :: < (Foo a) (Foo b) a b Generated lens with $ turned on: foo :: 8 (Foo a) a #This option is disabled by default.% microlens-th0Supply type signatures for the generated lenses.This option is enabled by default. Disable it if you want to write the signature by yourself @ for instance, if the signature should be more restricted, or if you want to write haddocks for the lens (as haddocks are attached to the signature and not to the definition).& microlens-th/Generate @updateable@ optics. When turned off, Es will be generated instead of =s and Fs will be generated instead of <es.This option is enabled by default. Disabling it can be useful for types with invariants (also known as @types with smart constructors@) @ if you generate updateable optics, anyone would be able to use them to break your invariants.' microlens-thGenerate lenses using lazy pattern matches. This can allow fields of an undefined value to be initialized with lenses: 8data Foo = Foo {_x :: Int, _y :: Bool} deriving Show ! (+ B ' C True) ''Foo  >>> G B x C 8 B y C True Foo {_x = 8, _y = True}  (Without ', the result would be just G.)This option is disabled by default. The downside of enabling it is that it can lead to space-leaks and code-size/compile-time increases when lenses are generated for large records.When you have a lazy lens, you can get a strict lens from it by composing with (H): strictLens = (H ) . lazyLens ( microlens-thThis lets you choose which fields would have lenses generated for them and how would those lenses be called. To do that, you provide a function that would take a field name and output a list (possibly empty) of lenses that should be generated for that field.9Here's the full type of the function you have to provide: 38 -> -- The datatype lenses are being generated for [3/] -> -- A list of all fields of the datatype 3 -> -- The current field [] -- A list of lens names Most of the time you won't need the first 2 parameters, but sometimes they are useful @ for instance, the list of all fields would be useful if you wanted to implement a slightly more complicated rule like @if some fields are prefixed with underscores, generate lenses for them, but if no fields are prefixed with underscores, generate lenses for all fields@.As an example, here's a function used by default. It strips @_@ off the field name, lowercases the next character after @_@, and skips the field entirely if it doesn't start with @_@: \_ _ n -> case I n of '_':x:xs -> [ (J (K x : xs))] _ -> [] )You can also generate classes (i.e. what " does) by using  className lensName instead of  lensName.) microlens-thThis lets you choose whether a class would be generated for the type itself (like # does). If so, you can choose the name of the class and the name of the type-specific lens.For  and " this is just  const Nothing. For #$ this function is defined like this:  \n -> case I n of x:xs -> Just (J (Has ++ x:xs), J (K x : xs)) [] -> Nothing * microlens-th7Decide whether generation of classes is allowed at all.If this is disabled, neither " nor #% would work, regardless of values of ( or ). On the other hand, if ( and ) don't generate any classes, enabling this won't have any effect.+ microlens-th$Lens rules used by default (i.e. in ):% is turned on& is turned on' is turned off$ is turned off( strips @_@ off the field name, lowercases the next character after @_@, and skips the field entirely if it doesn't start with @_@ (you can see how it's implemented in the docs for ()) isn't used (i.e. defined as  const Nothing), microlens-thA modification of + used by   (the only difference is that a simple lookup function is used for ().- microlens-thLens rules used by ":% is turned on& is turned on' is turned off$ is turned on (unlike in +)( is more complicated @ it takes fields which are prefixed with the name of the type they belong to (e.g. @fooFieldName@ for @Foo@), strips that prefix, and generates a class called @HasFieldName@ with a single method called @fieldName@. If some fields are prefixed with underscores, underscores would be stripped too, but then fields without underscores won't have any lenses generated for them. Also note that e.g. @foolish@ won't have a lens called @lish@ generated for it @ the prefix must be followed by a capital letter (or else it wouldn't be camel case).) isn't used (i.e. defined as  const Nothing). microlens-thLike standard rules used by ", but doesn't put any restrictions on the prefix. I.e. if you have fields called  _fooBarBaz _someX someY*then the generated lenses would be called barBaz and x./ microlens-thLens rules used by #:% is turned on& is turned on' is turned off$ is turned on (unlike in +)( is the same as in +) just adds @Has@ to the name of the type (so for @Person@ the generated class would be called @HasPerson@ and the type-specific lens in that class would be called @person@)L microlens-thCompute the field optics for a deconstructed datatype Dec When possible build an Iso otherwise build one optic per field.M microlens-thBuild an instance for a field. If the field@s type contains any type families, will produce an equality constraint to avoid a type family application in the instance head., microlens-th [(fieldName, lensName)]N microlens-th(constructor name, field name, field typeO microlens-thOuter s type P microlens-thOuter s type Q microlens-thOuter s type R microlens-th8optic type, definition type, field count, target fields  !"#$%&'()*+,-./ !"#+,/-.()*$%&'      !"#$%&'()*+,-./01234567867967:67;67<=>?@AB@CD@EF=>G=>H=>I=JK=JL@MN@OP=JQ@MR=>S=>T@UV@MW67X67Y@Z[\]^_`ab,microlens-th-0.4.3.14-KqmMHOUvFZj67CAeHMpwXtLens.Micro.TH.Internal Lens.Micro.TH HasTypeVars typeVarsExHasNamenamenewNamestypeVars substTypeVars inlinePragmaconAppsTdatatypeTypeKinded quantifyType quantifyType' tvbToTypeunSigTelemOflengthOfsetOf_ForallT $fHasNameCon $fHasNameName$fHasNameTyVarBndr$fHasTypeVarsMaybe$fHasTypeVars[]$fHasTypeVarsCon$fHasTypeVarsType$fHasTypeVarsName$fHasTypeVarsTyVarBndrDefNameTopName MethodName LensRules makeLenses makeLensesFormakeLensesWith makeFields makeClassy simpleLensesgenerateSignaturesgenerateUpdateableOpticsgenerateLazyPatterns lensField lensClass createClass lensRules lensRulesForcamelCaseFieldsabbreviatedFields classyRules $fShowDefName $fEqDefName $fOrdDefNametemplate-haskellLanguage.Haskell.TH.SyntaxName TyVarBndrTypeGadtCRecGadtC)microlens-0.4.13.1-5Q580NbiDM6AM43K2os1L8Lens.Micro.TypeLens'base Data.Functor<$> Data.FoldableconcatData.TraversablemapMLens Traversal Traversal' Lens.Micro^?^?!GHC.Base<*> Data.Function&.~flip SimpleFold SimpleGetterGHC.Err undefined$!nameBasemkName GHC.UnicodetoLowermakeFieldOpticsForDatatypemakeFieldInstancenormalizeConstructormakeClassyDrivermakeClassyClassmakeClassyInstance buildScaffold