úÎeCc     NoneThis function takes a getter and setter! function and returns our lense. ,Usually you only need to use this if you don'>t want to use Template Haskell to derive your Lenses for you. With a structure Point:   data Point = Point {  x_ :: Float,  y_ :: Float  }  deriving (Show)  This (from Data.Lenses.Template): $( deriveLenses ''Point ) is equivalent to this: 6 x :: (MonadState Point m) => StateT Float m b -> m b * x = fromGetSet x_ (\a s -> s { x_ = a }) 6 y :: (MonadState Point m) => StateT Float m b -> m b * y = fromGetSet y_ (\a s -> s { y_ = a }) 0fetches a field from a structure using a lense:   somePoint = Point 5 3  a = somePoint `fetch` x  b = somePoint `fetch` y  -- a == 5  -- b == 3 .updates a field in a structure using a lense:   somePoint = Point 5 3 & newPoint = (somePoint `update` y) 15  -- newPoint == Point 5 15 <alters a field in a structure using a lense and a function:   somePoint = Point 5 3 ' newPoint = (somePoint `alter` y) (+1)  -- newPoint == Point 5 4 sRuns a state monad action on a structure and returns the value returned from the action and the updated structure.  somePoint = Point 5 3 - a = runOn somePoint $ x (modifyAndGet (+1))  -- a == (6, Point 6 3) Monad transformer version of  . Note that  = . YRuns a state monad action on a structure and returns the value returned from the action. $Use it to fetch values from fields.  > someTriangle = Triangle (Point 5 3) (Point 0 1) (Point 10 6) ( a = evalFrom someTriangle $ pb . x get  -- a == 0  note that:  E evalFrom someTriangle (pb . x get) == someTriangle `fetch` (pb . x) The advantage over C is that it allows you to specify a different final action besides  like so: 4 evalFrom someTriangle $ pb . x (modifyAndGet (+1)) Monad transformer version of  . Note that  =  . KRuns a state monad action on a structure and returns the updated structure Use it to update fields:   somePoint = Point 5 3 " a = execIn somePoint $ x (put 1)  -- a == Point 1 3  note that:  : execIn somePoint (x (put 1)) == (somePoint `update` x) 1 The advantage over C is that it allows you to specify a different final action besides  like so: . a = execIn somePoint $ x (modifyAndGet (+1))  -- a = Point 6 3 Monad transformer version of  . Note that  =  . ¦This function has the magical ability to convert a function that fetches elements from a structure, to a function that lets you modify the elements in the structure. 4The catch is that the structure must be a member of . FSo say you have a function that gets the diagonal of a list of lists:   diagonal :: [[a]] -> [a] =we can make a function that increments the diagonal like so:   addOne :: State Int ()  addOne = modify (+1)  % incrementDiagonal :: [[a]] -> [[a]] K incrementDiagonal xss = snd $ runSTLense (fmap ($ addOne) . diagonal) xss BOf course there are some helper combinators to make this cleaner:  ; incrementDiagonal xss = (addOne `to` diagonal) `from` xss  h takes a function, a traversable structure, and returns a pair of (collected values, updated structure) For clarification:  Q specialFunction :: (Traversable f, Traversable t) => f (State a b -> s) -> t s T (collectedValues, updatedStructure) = runSTLense specialFunction originalStructure D collectedAlmostValues = specialFunction processedOriginalStructure •processedOriginalStructure has the same shape as originalStructure but every element has been replaced with a transformer function (State a b -> s). specialFunction needs to return the result of the application of the functions in processedOriginalStructure to a state monad. —The state monad by definition will return a result and potentially update state. Getting state will get the value of the element in originalStructure. ~Updating state will update the value of the element in updatedStructure. The returned values are gathered in collectedValues. [A helper combinator used for applying a monad to element collected by a fetching function.  For example:   everyOther :: [a] -> [a]  everyOther [] = []  everyOther (x:[]) = [x] ) everyOther (x:y:xs) = x : everyOther xs   addOne :: State Int ()  addOne = modify (+1)   test :: [Int] > test = (addOne `to` everyOther) `from` [1, 2, 9, 6, 7, 8, 4] # -- test == [2, 2, 10, 6, 8, 8, 5] which is the same as:  H test = snd $ runSTLense (addOne `to` everyOther) [1, 2, 9, 6, 7, 8, 4] which is the same as: N test = snd $ runSTLense (fmap ($ addOne) . everyOther) [1, 2, 9, 6, 7, 8, 4] Applies  / to a function and a structure and returns the  of the result. See   for example of use. DModifies the state in a state monad and returns the original value.   and  should really be in  ?Modifies the state in a state monad and returns the new value. FAn operator for assigning a value to the value referenced by a lense. K(see the example near the end of the tutorial at the start of this module) Flipped version of '($)'.     NonederiveLenses n where n is the name of a data type  declared with data' looks through all the declared fields > of the data type, and for each field ending in an underscore @ generates an accessor of the same name without the underscore. It is nameDeriveLenses n f where f satisfies   f (s ++ "_") = Just s ( f x = Nothing -- otherwise "For example, given the data type:  & data Score = Score { p1Score_ :: Int & , p2Score_ :: Int & , rounds :: Int  }  deriveLenses& will generate the following objects:  : p1Score :: (MonadState Score m) => StateT Int m b -> m b < p1Score = fromGetSet p1Score_ (\x s -> s { p1Score_ = x }) : p2Score :: (MonadState Score m) => StateT Int m b -> m b < p2Score = fromGetSet p2Score_ (\x s -> s { p2Score_ = x }) .It is used with Template Haskell syntax like:   $( deriveLenses ''TypeName ) 7And will generate accessors when TypeName was declared  using data or newtype. nameDeriveLenses n f where n is the name of a data type  declared with data and f$ is a function from names of fields A in that data type to the name of the corresponding accessor. If  f returns Nothing), then no accessor is generated for that  field.       !"#$%&'()* lenses-0.1.6 Data.LensesData.Lenses.TemplateControl.Monad.StateClass fromGetSetfetchupdatealterrunOnrunOnTevalFrom evalFromTexecInexecInT runSTLensetofrom getAndModify modifyAndGet$=$% deriveLensesnameDeriveLensestransformers-0.3.0.0Control.Monad.Trans.State.Lazy runStateT mtl-2.1.2Control.Monad.State.ClassgetbaseGHC.Baseflip evalStateTput execStateTData.Traversable Traversable Data.TuplesndstripUnderscore namedFields