úÎMKAa°      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯TemplateHaskell experimentalEdward Kmett <ekmett@gmail.com> Trustworthy*Derive lenses for the record selectors in ( a single-constructor data declaration, 6 or for the record selector in a newtype declaration. 7 Lenses will only be generated for record fields which " are prefixed with an underscore. Example usage:  makeLenses ''Foo /Derive lenses, specifying explicit pairings of (fieldName, lensName). Example usage: < makeLensesFor [("_foo", "fooLens"), ("bar", "lbar")] ''Foo 4Derive lenses with the provided name transformation ! and filtering function. Produce  Just lensName to generate a lens  of the resultant name, or Nothing to not generate a lens  for the input record name. Example usage: , makeLensesBy (\n -> Just (n ++ "L")) ''Foo the name transformer  Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-Infered  Used for  maximumOf  Used for  minimumOf Used internally by ° and the like. Used internally by  traverseOf_, ° and the like. Applicative composition of  State Int with a ±, used  by  elementOf,  elementsOf, traverseElement, traverseElementsOf 0The indexed store can be used to characterize a  LensFamily  and is used by clone Used by Focus Obtain the minimum Obtain the maximum  ²³´µ¶·¸¹º      ²³´µ¶·¸¹º Rank2Types provisionalEdward Kmett <ekmett@gmail.com> Safe-Infered‚=Types that support traversal of the value of the maximal key This is separate from  because a min-heap < or max-heap may be able to support one, but not the other. 'Traverse the value for the maximal key =Types that support traversal of the value of the minimal key This is separate from  because a min-heap < or max-heap may be able to support one, but not the other. 'Traverse the value for the minimal key  Provides ad hoc overloading for  (Traverse the individual characters in a » ; anyOf traverseText (=='c') :: TraverseText b => b -> Bool  Provides ad hoc overloading for   #Traverse the individual bytes in a ¼ H anyOf traverseByteString (==0x80) :: TraverseByteString b => b -> Bool !A !I describes how to retrieve multiple values in a way that can be composed % with other lens-like constructions. A ! a b c dC provides a structure with operations very similar to those of the ½  typeclass, see f and the other ! combinators. !By convention, if there exists a foo method that expects a ½ (f c), then there should be a  fooOf method that takes a ! a b c d and a value of type a. A # is a legal ! that just ignores the supplied ¾  Unlike a + a ! is read-only. Since a ! cannot be used to write back 3 there are no lens laws that can be applied to it. In practice the b and dA are left dangling and unused, and as such is no real point in a * !. = type Fold a b c d = forall m. Monoid m => Getting m a b c d "Most #- combinators are able to be used with both a # or a ! in S limited situations, to do so, they need to be monomorphic in what we are going to  extract with ¿. If a function accepts a Getting r a b c d , then when r is a Monoid, you can  pass a ! (or +&), otherwise you can only pass this a # or ,. 5 type Getting r a b c d = LensLike (Const r) a b c d #A #M describes how to retrieve a single value in a way that can be composed with  other lens-like constructions.  Unlike a , a # is read-only. Since a # cannot be used to write back 3 there are no lens laws that can be applied to it.  Moreover, a # can be used directly as a !, since it just ignores the ¾. In practice the b and d? are left dangling and unused, and as such is no real point in  using a * #. ;type Getter a b c d = forall z. LensLike (Const z) a b c d $ The only ,-like law that can apply to a $ l is that  ! set l c (set l b a) = set l c a You can't G a $3 in general, so the other two laws are irrelevant. You can compose a $ with a , or a + using (.) from the Prelude ! and the result is always only a $ and nothing more. 1 type Setter a b c d = LensLike Identity a b c d %This class allows us to use &. on a number of different monad transformers. &IRun a monadic action in a larger context than it was defined in, using a * , or * +. lThis is commonly used to lift actions in a simpler state monad into a state monad with a larger state type. When applied to a 'Simple +M over multiple values, the actions for each target are executed sequentially + and the results are aggregated monoidally  and a monoidal summary  of the result is given. N focus :: Monad m => Simple Lens a b -> st b m c -> st a m c N focus :: (Monad m, Monoid c) => Simple Traversal a b -> st b m c -> st a m c 'Like &4, but discarding any accumulated results as you go. P focus_ :: Monad m => Simple Lens a b -> st b m c -> st a m () P focus_ :: (Monad m, Monoid c) => Simple Traversal a b -> st b m c -> st a m () (A much more limited version of & that can work with a $. )Many combinators that accept a , can also accept a + in limited situations. 'They do so by specializing the type of ±" that they require of the caller. If a function accepts a ) f a b c d for some ± f, then they may be passed a ,.  Further, if f is an À, they may also be passed a +. *A * ,, * +, ... can be used instead of a ,,+, ...  whenever the type variables don't change upon setting a value. ( imaginary :: Simple Lens (Complex a) a ( traverseHead :: Simple Traversal [a] a +A + can be used directly as a $ or a ! (but not as a ,) and provides V the ability to both read and update multiple fields, subject to some relatively weak + laws. UThese have also been known as multilenses, but they have the signature and spirit of  8 traverse :: Traversable f => Traversal (f a) (f b) a b 8and the more evocative name suggests their application. ,A ,+ is actually a lens family as described in  /http://comonad.com/reader/2012/mirrored-lenses/. 2With great power comes great responsibility and a , is subject to the lens laws:   view l (set l b a) = b  set l (view l a) a = a ! set l c (set l b a) = set l c a =These laws are strong enough that the 4 type parameters of a ,. cannot vary fully independently. For more on  how they interact, read the Why is it a Lens Family? section of  /http://comonad.com/reader/2012/mirrored-lenses/. Every , can be used directly as a #, $, ! or +. 0 identity :: Lens (Identity a) (Identity b) a b , identity f (Identity a) = Identity <$> f a -Build a , from a getter and a setter. J lens :: Functor f => (a -> c) -> (a -> d -> b) -> (c -> f d) -> a -> f b .Built a , from an isomorphism family D iso :: Functor f => (a -> c) -> (d -> b) -> (c -> f d) -> a -> f b /(/') can be used in one of two scenarios: When applied to a , , it can edit the target of the , in a structure, extracting a - supplemental result, and the new structure. When applied to a +!, it can edit the targets of the  Traversals, extracting a / supplemental monoidal summary of its actions. 8For all that the definition of this combinator is just:   (%%~) = id [It may be beneficial to think about it as if it had these more restrictive types, however: H (%%~) :: Lens a b c d -> (c -> (e, d)) -> a -> (e, b) H (%%~) :: Monoid m => Traversal a b c d -> (c -> (m, d)) -> a -> (m, b) 0Modify the target of a ,: in the current state returning some extra information of c or  modify all targets of a +< in the current state, extracting extra information of type c / and return a monoidal summary of the changes.   (%%=) = (state.) It may be useful to think of (0>), instead, as having either of the following more restricted  type signatures: Q (%%=) :: MonadState a m => Lens a a c d -> (c -> (e, d) -> m e Q (%%=) :: (MonadState a m, Monoid e) => Traversal a a c d -> (c -> (e, d) -> m e 1AMap each element of a structure targeted by a Lens or Traversal, E evaluate these actions from left to right, and collect the results.   traverseOf = id   traverse = traverseOf traverse ; traverseOf :: Lens a b c d -> (c -> f d) -> a -> f b ; traverseOf :: Traversal a b c d -> (c -> f d) -> a -> f b 2  forOf = flip  forOf l = flip (traverseOf l)  for = forOf traverse 3FEvaluate each action in the structure from left to right, and collect  the results.  " sequenceA = sequenceAOf traverse ! sequenceAOf l = traverseOf l id  sequenceAOf l = l id > sequenceAOf :: Lens a b (f c) c -> a -> f b C sequenceAOf :: Applicative f => Traversal a b (f c) c -> a -> f b 4HMap each element of a structure targeted by a lens to a monadic action, E evaluate these actions from left to right, and collect the results.   mapM = mapMOf traverse B mapMOf :: Lens a b c d -> (c -> m d) -> a -> m b B mapMOf :: Monad m => Traversal a b c d -> (c -> m d) -> a -> m b 5  forM = forMOf traverse  forMOf l = flip (mapMOf l) = forMOf :: Lens a b c d -> a -> (c -> m d) -> m b = forMOf :: Monad m => Lens a b c d -> a -> (c -> m d) -> m b 6  sequence = sequenceOf traverse  sequenceOf l = mapMOf l id * sequenceOf l = unwrapMonad . l WrapMonad < sequenceOf :: Lens a b (m c) c -> a -> m b < sequenceOf :: Monad m => Traversal a b (m c) c -> a -> m b 7This generalizes Á to an arbitrary +.  " transpose = transposeOf traverse  . ghci> transposeOf traverse [[1,2,3],[4,5,6]]  [[1,4],[2,5],[3,6]]  Since every ,. is a Traversal, we can use this as a form of  monadic strength. ( transposeOf _2 :: (b, [a]) -> [(b, a)] 8;This setter can be used to map over all of the values in a ±.  fmap = adjust mapped  fmapDefault = adjust traverse  (<$) = set mapped 9Build a Setter.  sets . adjust = id  adjust . sets = id :Modify the target of a , or all the targets of a $ or +  with a function.   fmap = adjust mapped  fmapDefault = adjust traverse  sets . adjust = id  adjust . sets = id ;Replace the target of a , or all of the targets of a $  or + with a constant value.  (<$) = set mapped <Modifies the target of a , or all of the targets of a $ or  + with a user supplied function. This is an infix version of :   fmap f = mapped %~ f  fmapDefault f = traverse %~ f " ghci> _2 %~ length $ (1,"hello")  (1,5) =Replace the target of a , or all of the targets of a $  or + with a constant value. This is an infix version of ;   f <$ a = mapped ^~ f $ a  ghci> bitAt 0 ^~ True $ 0  1 >0Increment the target(s) of a numerically valued ,, Setter' or +  ghci> _1 +~ 1 $ (1,2)  (2,2) ?/Multiply the target(s) of a numerically valued ,, $ or +  ghci> _2 *~ 4 $ (1,2)  (1,8) @0Decrement the target(s) of a numerically valued ,, $ or +  ghci> _1 -~ 2 $ (1,2)  (-1,2) A-Divide the target(s) of a numerically valued ,, $ or + B Logically  the target(s) of a Ã-valued , or $ C Logically Ä the target(s) of a Ã-valued , or $ DBitwise Å the target(s) of a Ã-valued , or $ EBitwise Æ the target(s) of a Ã-valued , or $ FBuild a #% from an arbitrary Haskell function.  to f . to g = to (g . f) GView the value pointed to by a # or , or the result of folding over  all the results of a ! or +# that points at a monoidal values. It may be useful to think of G. as having these more restrictive signatures:  1 view :: Lens a b c d -> a -> c 1 view :: Getter a b c d -> a -> c 1 view :: Monoid m => Fold a b m d -> a -> m 1 view :: Monoid m => Traversal a b m d -> a -> m 8 view :: ((c -> Const c d) -> a -> Const c b) -> a -> c HView the value of a #, ,# or the result of folding over the $ result of mapping the targets of a ! or +. It may be useful to think of H. as having these more restrictive signatures:  > views :: Getter a b c d -> (c -> d) -> a -> d > views :: Lens a b c d -> (c -> d) -> a -> d > views :: Monoid m => Fold a b c d -> (c -> m) -> a -> m > views :: Monoid m => Traversal a b c d -> (c -> m) -> a -> m E views :: ((c -> Const m d) -> a -> Const m b) -> (c -> m) -> a -> m IView the value pointed to by a # or , or the result of folding over  all the results of a ! or +# that points at a monoidal values. This is the same operation as G, only infix.  1 (^$) :: Lens a b c d -> a -> c 1 (^$) :: Getter a b c d -> a -> c 1 (^$) :: Monoid m => Fold a b m d -> a -> m 1 (^$) :: Monoid m => Traversal a b m d -> a -> m 8 (^$) :: ((c -> Const c d) -> a -> Const c b) -> a -> c JView the value pointed to by a # or , or the result of folding over  all the results of a ! or +# that points at a monoidal values. This is the same operation as G with the arguments flipped. HThe fixity and semantics are such that subsequent field accesses can be  performed with (Prelude..)  , ghci> ((0, 1 :+ 2), 3)^._1._2.to magnitude  2.23606797749979  1 (^.) :: a -> Lens a b c d -> c 1 (^.) :: a -> Getter a b c d -> c 1 (^.) :: Monoid m => a -> Fold a b m d -> m 1 (^.) :: Monoid m => a -> Traversal a b m d -> m 8 (^.) :: a -> ((c -> Const c d) -> a -> Const c b) -> c KJThis is a lens that can change the value (and type) of the first field of  a pair.   ghci> (1,2)^._1  1   ghci> _1 +~ "hello" $ (1,2)  ("hello",2) 3 _1 :: Functor f => (a -> f b) -> (a,c) -> f (a,c) LAs K&, but for the second field of a pair.  + anyOf _2 :: (c -> Bool) -> (a, c) -> Bool Y traverse._2 :: (Applicative f, Traversable t) => (a -> f b) -> t (c, a) -> f (t (c, b)) S foldMapOf (traverse._2) :: (Traversable t, Monoid m) => (c -> m) -> t (b, c) -> m 3 _2 :: Functor f => (a -> f b) -> (c,a) -> f (c,b) MThis ,K can be used to read, write or delete the value associated with a key in a Ç.  6 ghci> Map.fromList [("hello",12)] ^. valueAt "hello"  Just 12 M valueAt :: Ord k => k -> (Maybe v -> f (Maybe v)) -> Map k v -> f (Map k v) NThis ,5 can be used to read, write or delete a member of an È.  6 ghci> IntMap.fromList [(1,"hello")] ^. valueAtInt 1  Just "hello"  A ghci> valueAtInt 2 +~ "goodbye" $ IntMap.fromList [(1,"hello")] & fromList [(1,"hello"),(2,"goodbye")] K valueAtInt :: Int -> (Maybe v -> f (Maybe v)) -> IntMap v -> f (IntMap v) OThis ,4 can be used to read, write or delete a member of a É  4 ghci> contains 3 +~ False $ Set.fromList [1,2,3,4]  fromList [1,2,4] B contains :: Ord k => k -> (Bool -> f Bool) -> Set k -> f (Set k) PThis ,5 can be used to read, write or delete a member of an Ê  : ghci> containsInt 3 +~ False $ IntSet.fromList [1,2,3,4]  fromList [1,2,4] > containsInt :: Int -> (Bool -> f Bool) -> IntSet -> f IntSet QCThis lens can be used to access the contents of the Identity monad RFThis lens can be used to access the value of the nth bit in a number. bitsAt n is only a legal , into b if 0 <= n < bitSize (undefined :: b) SHThis lens can be used to change the result of a function but only where $ the arguments match the key given. T)Access the real part of a complex number ? real :: Functor f => (a -> f a) -> Complex a -> f (Complex a) U.Access the imaginary part of a complex number D imaginary :: Functor f => (a -> f a) -> Complex a -> f (Complex a) VThis isn't quite a legal lens. Notably the view l (set l b a) = b law L is violated when you set a polar value with 0 magnitude and non-zero phase ) as the phase information is lost. So don' t do that! 0Otherwise, this is a perfectly convenient lens. K polarize :: Functor f => ((a,a) -> f (a,a)) -> Complex a -> f (Complex a) WUse the target of a , or # in the current state, or use a  summary of a ! or +" that points to a monoidal value.  ? use :: MonadState a m => Getter a b c d -> m c ? use :: MonadState a m => Lens a b c d -> m c ? use :: (MonadState a m, Monoid c) => Fold a b c d -> m c ? use :: (MonadState a m, Monoid c) => Traversal a b c d -> m c F use :: MonadState a m => ((c -> Const c d) -> a -> Const c b) -> m c XUse the target of a , or # in the current state, or use a  summary of a ! or +" that points to a monoidal value.  L uses :: MonadState a m => Getter a b c d -> (c -> e) -> m e L uses :: MonadState a m => Lens a b c d -> (c -> e) -> m e L uses :: (MonadState a m, Monoid c) => Fold a b c d -> (c -> e) -> m e L uses :: (MonadState a m, Monoid c) => Traversal a b c d -> (c -> e) -> m e S uses :: MonadState a m => ((c -> Const e d) -> a -> Const e b) -> (c -> e) -> m e YReplace the target of a , or all of the targets of a $ or + in our monadic 2 state with a new value, irrespective of the old. ZMap over the target of a , or all of the targets of a $ or ' Traversal in our monadic state. [Modify the target(s) of a * ,, $ or + by adding a value  Example:  fresh = do  id += 1  access id \Modify the target(s) of a * ,, $ or + by subtracting a value ]Modify the target(s) of a * ,, $ or + by multiplying by value ^Modify the target(s) of a * ,, $ or + by dividing by a value _Modify the target(s) of a * ,, $ or + by taking their logical Ä with a value `Modify the target(s) of a * ,, $ or + by taking their logical  with a value aModify the target(s) of a * ,, $ or + by computing its bitwise Æ with another value. bModify the target(s) of a * ,, $ or + by computing its bitwise Å with another value. c Obtain a ! from any ½ d Obtain a ! by filtering a ,, 'Getter, ! or +. e Obtain a !+ by reversing the order of traversal for a ,, #, ! or +. Of course, reversing a ! or # has no effect. f  foldMap = foldMapOf folded   foldMapOf = views B foldMapOf :: Getter a b c d -> (c -> m) -> a -> m B foldMapOf :: Lens a b c d -> (c -> m) -> a -> m B foldMapOf :: Monoid m => Fold a b c d -> (c -> m) -> a -> m B foldMapOf :: Monoid m => Traversal a b c d -> (c -> m) -> a -> m g  fold = foldOf folded   foldOf = view 3 foldOf :: Getter a b m d -> a -> m 3 foldOf :: Lens a b m d -> a -> m 3 foldOf :: Monoid m => Fold a b m d -> a -> m 3 foldOf :: Monoid m => Traversal a b m d -> a -> m hIRight-associative fold of parts of a structure that are viewed through a ,, #, ! or +.   foldr = foldrOf folded > foldrOf :: Getter a b c d -> (c -> e -> e) -> e -> a -> e > foldrOf :: Lens a b c d -> (c -> e -> e) -> e -> a -> e > foldrOf :: Fold a b c d -> (c -> e -> e) -> e -> a -> e > foldrOf :: Traversal a b c d -> (c -> e -> e) -> e -> a -> e iLLeft-associative fold of the parts of a structure that are viewed through a ,, #, ! or +.   foldl = foldlOf folded > foldlOf :: Getter a b c d -> (e -> c -> e) -> e -> a -> e > foldlOf :: Lens a b c d -> (e -> c -> e) -> e -> a -> e > foldlOf :: Fold a b c d -> (e -> c -> e) -> e -> a -> e > foldlOf :: Traversal a b c d -> (e -> c -> e) -> e -> a -> e j  toList = toListOf folded + toListOf :: Getter a b c d -> a -> [c] + toListOf :: Lens a b c d -> a -> [c] + toListOf :: Fold a b c d -> a -> [c] + toListOf :: Traversal a b c d -> a -> [c] k  and = andOf folded + andOf :: Getter a b Bool d -> a -> Bool + andOf :: Lens a b Bool d -> a -> Bool + andOf :: Fold a b Bool d -> a -> Bool + andOf :: Traversl a b Bool d -> a -> Bool l  or = orOf folded + orOf :: Getter a b Bool d -> a -> Bool + orOf :: Lens a b Bool d -> a -> Bool + orOf :: Fold a b Bool d -> a -> Bool + orOf :: Traversal a b Bool d -> a -> Bool m  any = anyOf folded 8 anyOf :: Getter a b c d -> (c -> Bool) -> a -> Bool 8 anyOf :: Lens a b c d -> (c -> Bool) -> a -> Bool 8 anyOf :: Fold a b c d -> (c -> Bool) -> a -> Bool 8 anyOf :: Traversal a b c d -> (c -> Bool) -> a -> Bool n  all = allOf folded 8 allOf :: Getter a b c d -> (c -> Bool) -> a -> Bool 8 allOf :: Lens a b c d -> (c -> Bool) -> a -> Bool 8 allOf :: Fold a b c d -> (c -> Bool) -> a -> Bool 8 allOf :: Traversal a b c d -> (c -> Bool) -> a -> Bool o  product = productOf folded 3 productOf :: Getter a b c d -> a -> c 3 productOf :: Lens a b c d -> a -> c 3 productOf :: Num c => Fold a b c d -> a -> c 3 productOf :: Num c => Traversal a b c d -> a -> c p  sum = sumOf folded   sumOf _1 :: (a, b) -> a ; sumOf (folded._1) :: (Foldable f, Num a) => f (a, b) -> a / sumOf :: Getter a b c d -> a -> c / sumOf :: Lens a b c d -> a -> c / sumOf :: Num c => Fold a b c d -> a -> c / sumOf :: Num c => Traversal a b c d -> a -> c qWhen passed a #, q can work over a ±. When passed a !, q requires an À.   traverse_ = traverseOf_ folded  > traverseOf_ _2 :: Functor f => (c -> f e) -> (c1, c) -> f () O traverseOf_ traverseLeft :: Applicative f => (a -> f b) -> Either a c -> f () bThe rather specific signature of traverseOf_ allows it to be used as if the signature was either: N traverseOf_ :: Functor f => Getter a b c d -> (c -> f e) -> a -> f () N traverseOf_ :: Functor f => Lens a b c d -> (c -> f e) -> a -> f () N traverseOf_ :: Applicative f => Fold a b c d -> (c -> f e) -> a -> f () N traverseOf_ :: Applicative f => Traversal a b c d -> (c -> f e) -> a -> f () r  for_ = forOf_ folded I forOf_ :: Functor f => Getter a b c d -> a -> (c -> f e) -> f () I forOf_ :: Functor f => Lens a b c d -> a -> (c -> f e) -> f () I forOf_ :: Applicative f => Fold a b c d -> a -> (c -> f e) -> f () I forOf_ :: Applicative f => Traversal a b c d -> a -> (c -> f e) -> f () s " sequenceA_ = sequenceAOf_ folded F sequenceAOf_ :: Functor f => Getter a b (f ()) d -> a -> f () F sequenceAOf_ :: Functor f => Lens a b (f ()) d -> a -> f () F sequenceAOf_ :: Applicative f => Fold a b (f ()) d -> a -> f () F sequenceAOf_ :: Applicative f => Traversal a b (f ()) d -> a -> f () t  mapM_ = mapMOf_ folded D mapMOf_ :: Monad m => Getter a b c d -> (c -> m e) -> a -> m () D mapMOf_ :: Monad m => Lens a b c d -> (c -> m e) -> a -> m () D mapMOf_ :: Monad m => Fold a b c d -> (c -> m e) -> a -> m () D mapMOf_ :: Monad m => Traversal a b c d -> (c -> m e) -> a -> m () u  forM_ = forMOf_ folded D forMOf_ :: Monad m => Getter a b c d -> a -> (c -> m e) -> m () D forMOf_ :: Monad m => Lens a b c d -> a -> (c -> m e) -> m () D forMOf_ :: Monad m => Fold a b c d -> a -> (c -> m e) -> m () D forMOf_ :: Monad m => Traversal a b c d -> a -> (c -> m e) -> m () v  sequence_ = sequenceOf_ folded > sequenceOf_ :: Monad m => Getter a b (m b) d -> a -> m () > sequenceOf_ :: Monad m => Lens a b (m b) d -> a -> m () > sequenceOf_ :: Monad m => Fold a b (m b) d -> a -> m () > sequenceOf_ :: Monad m => Traversal a b (m b) d -> a -> m () w1The sum of a collection of actions, generalizing |.   asum = asumOf folded : asumOf :: Alternative f => Getter a b c d -> a -> f c : asumOf :: Alternative f => Lens a b c d -> a -> f c : asumOf :: Alternative f => Fold a b c d -> a -> f c : asumOf :: Alternative f => Traversal a b c d -> a -> f c x1The sum of a collection of actions, generalizing |.   msum = msumOf folded 8 msumOf :: MonadPlus m => Getter a b c d -> a -> m c 8 msumOf :: MonadPlus m => Lens a b c d -> a -> m c 8 msumOf :: MonadPlus m => Fold a b c d -> a -> m c 8 msumOf :: MonadPlus m => Traversal a b c d -> a -> m c y  elem = elemOf folded 7 elemOf :: Eq c => Getter a b c d -> c -> a -> Bool 7 elemOf :: Eq c => Lens a b c d -> c -> a -> Bool 7 elemOf :: Eq c => Fold a b c d -> c -> a -> Bool 7 elemOf :: Eq c => Traversal a b c d -> c -> a -> Bool z  notElem = notElemOf folded : notElemOf :: Eq c => Getter a b c d -> c -> a -> Bool : notElemOf :: Eq c => Fold a b c d -> c -> a -> Bool : notElemOf :: Eq c => Lens a b c d -> c -> a -> Bool : notElemOf :: Eq c => Traversal a b c d -> c -> a -> Bool {  concatMap = concatMapOf folded < concatMapOf :: Getter a b c d -> (c -> [e]) -> a -> [e] < concatMapOf :: Lens a b c d -> (c -> [e]) -> a -> [e] < concatMapOf :: Fold a b c d -> (c -> [e]) -> a -> [e] < concatMapOf :: Traversal a b c d -> (c -> [e]) -> a -> [e] |  concat = concatOf folded * concatOf :: Getter a b [e] d -> a -> [e] ( concatOf :: Lens a b [e] d -> a -> [e] ( concatOf :: Fold a b [e] d -> a -> [e] # concatOf :: a b [e] d -> a -> [e] };Note: this can be rather inefficient for large containers.   length = lengthOf folded   lengthOf _1 :: (a, b) -> Int  lengthOf _1 = 1 : lengthOf (folded.folded) :: Foldable f => f (g a) -> Int + lengthOf :: Getter a b c d -> a -> Int + lengthOf :: Lens a b c d -> a -> Int + lengthOf :: Fold a b c d -> a -> Int + lengthOf :: Traversal a b c d -> a -> Int ~Returns Ë if this ! or +( has no targets in the given container. Note: nullOf on a valid , or # will always return Ì   null = nullOf folded /This may be rather inefficient compared to the Í check of many containers.   nullOf _1 :: (a, b) -> Int  nullOf _1 = False ? nullOf (folded._1.folded) :: Foldable f => f (g a, b) -> Bool * nullOf :: Getter a b c d -> a -> Bool * nullOf :: Lens a b c d -> a -> Bool * nullOf :: Fold a b c d -> a -> Bool * nullOf :: Traversal a b c d -> a -> Bool 2Obtain the maximum element (if any) targeted by a ! or + Note: maximumOf on a valid , or # will always return Î a value.  8 maximum = fromMaybe (error "empty") . maximumOf folded 9 maximumOf :: Getter a b c d -> a -> Maybe c 9 maximumOf :: Lens a b c d -> a -> Maybe c 9 maximumOf :: Ord c => Fold a b c d -> a -> Maybe c 9 maximumOf :: Ord c => Traversal a b c d -> a -> Maybe c €2Obtain the minimum element (if any) targeted by a ! or + Note: minimumOf on a valid , or # will always return Î a value.  8 minimum = fromMaybe (error "empty") . minimumOf folded 9 minimumOf :: Getter a b c d -> a -> Maybe c 9 minimumOf :: Lens a b c d -> a -> Maybe c 9 minimumOf :: Ord c => Fold a b c d -> a -> Maybe c 9 minimumOf :: Ord c => Traversal a b c d -> a -> Maybe c 2Obtain the maximum element (if any) targeted by a !, +, ,  or #( according to a user supplied ordering.  D maximumBy cmp = fromMaybe (error "empty") . maximumByOf folded cmp J maximumByOf :: Getter a b c d -> (c -> c -> Ordering) -> a -> Maybe c J maximumByOf :: Lens a b c d -> (c -> c -> Ordering) -> a -> Maybe c J maximumByOf :: Fold a b c d -> (c -> c -> Ordering) -> a -> Maybe c J maximumByOf :: Traversal a b c d -> (c -> c -> Ordering) -> a -> Maybe c ‚2Obtain the minimum element (if any) targeted by a !, +, ,  or #( according to a user supplied ordering.  D minimumBy cmp = fromMaybe (error "empty") . minimumByOf folded cmp J minimumByOf :: Getter a b c d -> (c -> c -> Ordering) -> a -> Maybe c J minimumByOf :: Lens a b c d -> (c -> c -> Ordering) -> a -> Maybe c J minimumByOf :: Fold a b c d -> (c -> c -> Ordering) -> a -> Maybe c J minimumByOf :: Traversal a b c d -> (c -> c -> Ordering) -> a -> Maybe c ƒThe ƒ@ function takes a lens, a predicate and a structure and returns B the leftmost element of the structure matching the predicate, or  Ï if there is no such element. „ A variant of hN that has no base case and thus may only be applied to lenses and structures A such that the lens views at least one element of the structure.  . foldr1Of l f = Prelude.foldr1 f . toListOf l   foldr1 = foldr1Of folded : foldr1Of :: Getter a b c d -> (c -> c -> c) -> a -> c : foldr1Of :: Lens a b c d -> (c -> c -> c) -> a -> c : foldr1Of :: Fold a b c d -> (c -> c -> c) -> a -> c : foldr1Of :: Traversal a b c d -> (c -> c -> c) -> a -> c … A variant of iQ that has no base case and thus may only be applied to lenses and strutures such < that the lens views at least one element of the structure.  . foldl1Of l f = Prelude.foldl1Of l f . toList   foldl1 = foldl1Of folded : foldl1Of :: Getter a b c d -> (c -> c -> c) -> a -> c : foldl1Of :: Lens a b c d -> (c -> c -> c) -> a -> c : foldl1Of :: Fold a b c d -> (c -> c -> c) -> a -> c : foldl1Of :: Traversal a b c d -> (c -> c -> c) -> a -> c †6Strictly fold right over the elements of a structure.   foldr' = foldrOf' folded ? foldrOf' :: Getter a b c d -> (c -> e -> e) -> e -> a -> e ? foldrOf' :: Lens a b c d -> (c -> e -> e) -> e -> a -> e ? foldrOf' :: Fold a b c d -> (c -> e -> e) -> e -> a -> e ? foldrOf' :: Traversal a b c d -> (c -> e -> e) -> e -> a -> e ‡NFold over the elements of a structure, associating to the left, but strictly.   foldl' = foldlOf' folded ? foldlOf' :: Getter a b c d -> (e -> c -> e) -> e -> a -> e ? foldlOf' :: Lens a b c d -> (e -> c -> e) -> e -> a -> e ? foldlOf' :: Fold a b c d -> (e -> c -> e) -> e -> a -> e ? foldlOf' :: Traversal a b c d -> (e -> c -> e) -> e -> a -> e ˆbMonadic fold over the elements of a structure, associating to the right, i.e. from right to left.   foldrM = foldrMOf folded N foldrMOf :: Monad m => Getter a b c d -> (c -> e -> m e) -> e -> a -> m e N foldrMOf :: Monad m => Lens a b c d -> (c -> e -> m e) -> e -> a -> m e N foldrMOf :: Monad m => Fold a b c d -> (c -> e -> m e) -> e -> a -> m e N foldrMOf :: Monad m => Traversal a b c d -> (c -> e -> m e) -> e -> a -> m e ‰aMonadic fold over the elements of a structure, associating to the left, i.e. from left to right.   foldlM = foldlMOf folded N foldlMOf :: Monad m => Getter a b c d -> (e -> c -> m e) -> e -> a -> m e N foldlMOf :: Monad m => Lens a b c d -> (e -> c -> m e) -> e -> a -> m e N foldlMOf :: Monad m => Fold a b c d -> (e -> c -> m e) -> e -> a -> m e N foldlMOf :: Monad m => Traversal a b c d -> (e -> c -> m e) -> e -> a -> m e ŠBThis is the traversal that never succeeds at returning any values < traverseNothing :: Applicative f => (c -> f d) -> a -> f a ‹ = traverseHead :: Applicative f => (a -> f a) -> [a] -> f [a] Œ*Traversal for editing the tail of a list. A traverseTail :: Applicative f => ([a] -> f [a]) -> [a] -> f [a] %Traverse the last element in a list.  # traverseLast = traverseValueAtMax = traverseLast :: Applicative f => (a -> f a) -> [a] -> f [a] Ž,Traverse all but the last element of a list A traverseInit :: Applicative f => ([a] -> f [a]) -> [a] -> f [a] ;A traversal for tweaking the left-hand value in an Either: M traverseLeft :: Applicative f => (a -> f b) -> Either a c -> f (Either b c) ,traverse the right-hand value in an Either:  N traverseRight :: Applicative f => (a -> f b) -> Either c a -> f (Either c a)  traverseRight = traverse Unfortunately the instance for 'Traversable (Either c)' is still missing from  base, so this can' t just be Ð ‘+Traverse the value at a given key in a Map X traverseValueAt :: (Applicative f, Ord k) => k -> (v -> f v) -> Map k v -> f (Map k v) * traverseValueAt k = valueAt k . traverse ’/Traverse the value at a given key in an IntMap V traverseValueAtInt :: Applicative f => Int -> (v -> f v) -> IntMap v -> f (IntMap v) 0 traverseValueAtInt k = valueAtInt k . traverse “6Traverse a single element in a traversable container. Z traverseElement :: (Applicative f, Traversable t) => Int -> (a -> f a) -> t a -> f (t a) ”WTraverse elements where a predicate holds on their position in a traversable container d traverseElements :: Applicative f, Traversable t) => (Int -> Bool) -> (a -> f a) -> t a -> f (t a) •(Traverse the typed value contained in a Ñ7 where the type required by your function matches that  of the contents of the Ñ. b traverseDynamic :: (Applicative f, Typeable a, Typeable b) => (a -> f b) -> Dynamic -> f Dynamic –Traverse the strongly typed Ò contained in Ó) where the type of your function matches  the desired Ò. r traverseException :: (Applicative f, Exception a, Exception b) => (a -> f b) -> SomeException -> f SomeException —*Traverse over all bits in a numeric type.  * ghci> toListOf traverseBits (5 :: Word8) 1 [True,False,True,False,False,False,False,False] %If you supply this an Integer, it won't crash, but the result will = be an infinite traversal that can be productively consumed.  ghci> toListOf traverseBits 5 K [True,False,True,False,False,False,False,False,False,False,False,False... ˜ Cloning a ,) is one way to make sure you arent given  something weaker, such as a + and can be used ? as a way to pass around lenses that have to be monomorphic in f. !Note: This only accepts a proper , , because  lacks its $ (admissable) Applicative instance. ™ Yields a + of the nth element of another + % traverseHead = elementOf traverse 0 šA + of the elements in another + where their positions in that + satisfy a predicate ) traverseTail = elementsOf traverse (>0) ’ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™šÔÕÖרÙÚÛÜÝÞßàáâã‚ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š‚,)+*-./0%&'(1234567MNOPRSQTUVKL$98:;=>@?ABCDE<Y[\]^`_baZ#F!cde"GHJIfghijmnklopqrstuvwx{|yz}~€‚ƒ†‡„…ˆ‰WXŠ‘’‹ŒŽ —•–“”™š˜‹ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™šÔÕÖרÙÚÛÜÝÞßàáâã RankNTypes provisionalEdward Kmett <ekmett@gmail.com> Safe-Infered›GSometimes you need to store a path lens into a container, but at least F at this time, impredicative polymorphism in GHC is somewhat lacking. FThis type provides a way to, say, store a list of polymorphic lenses. žRepresentable Functors. A ± f is ž if it is isomorphic to (x -> a) > for some x. All such functors can be represented by choosing x to be ? the set of lenses that are polymorphic in the contents of the ±,  that is to say  x = Rep f is a valid choice of x for every  ž ±. @Note: Some sources refer to covariant representable functors as ) corepresentable functors, and leave the " representable" name to 1 contravariant functors (those are isomorphic to (a -> x) for some x). LAs the covariant case is vastly more common, and both are often referred to = as representable functors, we choose to call these functors ž  here.  The representation of a ž ± as Lenses ¡¡# is a valid default definition for ä for a representable  functor.  $ fmapRep f m = rep $ \i -> f (m^.i) "Usage for a representable functor Foo:  instance Functor Foo where  fmap = fmapRep ¢¢# is a valid default definition for å and æ for a  representable functor.   pureRep = rep . const "Usage for a representable functor Foo:   instance Applicative Foo where  pure = pureRep  (<*>) = apRep  instance Monad Foo where  return = pureRep  (>>=) = bindRep ££# is a valid default definition for '( *)' for a representable  functor.  ) apRep mf ma = rep $ \i -> mf^.i $ ma^.i "Usage for a representable functor Foo:  instance Applicative Foo where  pure = pureRep  (<*>) = apRep ¤¤+ is a valid default default definition for '(>>=)' for a  representable functor.  & bindRep m f = rep $ \i -> f(m^.i)^.i "Usage for a representable functor Foo:  instance Monad ... where  return = pureRep  (>>=) = bindRep ¥A default definition for  for a ž ±  . distributeRep wf = rep $ \i -> fmap (^.i) wf Typical Usage: ! instance Distributive ... where  distribute = distributeRep ¦A ž ±. has a fixed shape. This fills each position  in it with a › § Map over a ž ±" with access to the lens for the  current position ) mapWithKey f m = rep $ \i -> f i (m^.i) ¨ Traverse a ž ±! with access to the current path © Traverse a ž ±! with access to the current path " as a lens, discarding the result ª Traverse a ž ±! with access to the current path ( and a lens (and the arguments flipped) «ç over a ž ±! with access to the current path  as a lens ¬ç over a ž ±! with access to the current path " as a lens, discarding the result ­ç over a ž ±! with access to the current path ( as a lens (with the arguments flipped) ® Fold over a ž ±! with access to the current path  as a lens, yielding a ¾ ¯ Fold over a ž ±! with access to the current path  as a lens. èCNB: The Eq requirement on this instance is a consequence of a lens  rather than e as the representation. ›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯è雜žŸ ¡¢£¤¥¦§¨©ª«¬­®¯žŸ ¡¢£¤¥›œ¦§®¯¨©ª«¬­›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯èéê        !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š››œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±¯²³´µ¶·¸¹º»¼½¾¿ÀÁ¯ÃįÅƯÇȯÇɽÊËÌÍÎÌÏÐÌÍѯÒÓ¯ÒÔÕÖ×ÕØÙÕÚÛÕÜÝÌÏÞÌÏßÀàá¯âã¯âä¯åæ¯çè¯éê¯éëìíîïðñòóôõö÷øùúû¯²ü¯Çý¯²þ¯åÿlens-1.0Control.Lens.THControl.Lens.Internal Control.LensControl.Lens.RepresentableData.Distributive distribute makeLenses makeLensesFor makeLensesByMaxNoMaxMinNoMinAction getAction Traversed getTraversed AppliedStaterunAppliedState IndexedStoreFocusing unfocusinggetMingetMaxTraverseValueAtMaxtraverseValueAtMaxTraverseValueAtMintraverseValueAtMin TraverseText traverseTextTraverseByteStringtraverseByteStringFoldGettingGetterSetterFocusfocusfocus_setFocusLensLikeSimple TraversalLenslensiso%%~%%= traverseOfforOf sequenceAOfmapMOfforMOf sequenceOf transposeOfmappedsetsadjustset%~^~+~*~-~//~||~&&~|~&~toviewviews^$^._1_2valueAt valueAtIntcontains containsIntidentitybitAtresultAtreal imaginarypolarizeuseuses^=%=+=-=*=//=&&=||=&=|=foldedfilteredreversed foldMapOffoldOffoldrOffoldlOftoListOfandOforOfanyOfallOf productOfsumOf traverseOf_forOf_ sequenceAOf_mapMOf_forMOf_ sequenceOf_asumOfmsumOfelemOf notElemOf concatMapOfconcatOflengthOfnullOf maximumOf minimumOf maximumByOf minimumByOffindOffoldr1Offoldl1OffoldrOf'foldlOf'foldrMOffoldlMOftraverseNothing traverseHead traverseTail traverseLast traverseInit traverseLeft traverseRighttraverseValueAttraverseValueAtInttraverseElementtraverseElementstraverseDynamictraverseException traverseBitsclone elementOf elementsOfKeyturn RepresentablerepRepfmapReppureRepapRepbindRep distributeRepkeys mapWithReptraverseWithReptraverseWithRep_ forWithRep mapMWithRep mapMWithRep_ forMWithRepfoldMapWithRep foldrWithRepbase Control.MonadmapM_GHC.BaseFunctor $fMonoidMax $fMonoidMin$fMonoidAction$fMonoidTraversed$fApplicativeAppliedState$fFunctorAppliedState$fFunctorIndexedStore$fApplicativeFocusing$fFunctorFocusing text-0.11.2.2Data.Text.InternalTextbytestring-0.9.2.1Data.ByteString.Lazy.Internal ByteString Data.FoldableFoldable Data.MonoidMonoidControl.ApplicativeConst Applicative Data.Text transposeghc-prim GHC.Classes|| GHC.TypesBool&& Data.Bits.|..&.containers-0.4.2.1Data.MapMap Data.IntMapIntMapData.SetSet Data.IntSetIntSetTrueFalseData.ByteStringnull Data.MaybeJustNothingData.Traversabletraverse Data.DynamicDynamic GHC.Exception Exception SomeException$fTraverseValueAtMaxSeq$fTraverseValueAtMax[]$fTraverseValueAtMaxIntMap$fTraverseValueAtMaxMap$fTraverseValueAtMinTree$fTraverseValueAtMinSeq$fTraverseValueAtMin[]$fTraverseValueAtMinIntMap$fTraverseValueAtMinMap$fTraverseTextText$fTraverseTextText0$fTraverseByteStringByteString$fTraverseByteStringByteString0$fFocusReaderT $fFocusStateT$fFocusStateT0fmappurereturnmapM$fRepresentable(->)$fRepresentableIdentity