Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

haddocks: some corrections and links, changed single line code blocks…

… to form @\ncode\n@, ACT II
  • Loading branch information...
commit f502561ad1dda7dde0b468d7ec4d75bcafddb932 1 parent d5c0462
Bas Dirks basdirks authored
44 src/Control/Lens/Getter.hs
View
@@ -89,9 +89,13 @@ infixl 8 ^., ^@.
-- | Build a 'Getter' from an arbitrary Haskell function.
--
--- @'to' f '.' 'to' g ≡ 'to' (g '.' f)@
+-- @
+-- 'to' f '.' 'to' g ≡ 'to' (g '.' f)
+-- @
--
--- @a '^.' 'to' f ≡ f a@
+-- @
+-- a '^.' 'to' f ≡ f a
+-- @
--
-- >>> a ^.to f
-- f a
@@ -142,7 +146,9 @@ type Accessing p m s t a b = p a (Accessor m b) -> s -> Accessor m t
-- 'Control.Lens.Fold.Fold' or 'Control.Lens.Traversal.Traversal' that points
-- at a monoidal value.
--
--- @'view' '.' 'to' ≡ 'id'@
+-- @
+-- 'view' '.' 'to' ≡ 'id'
+-- @
--
-- >>> view (to f) a
-- f a
@@ -185,7 +191,9 @@ view l = Reader.asks (runAccessor #. l Accessor)
-- the targets of a 'Control.Lens.Fold.Fold' or
-- 'Control.Lens.Traversal.Traversal'.
--
--- @'views' l f ≡ 'view' (l '.' 'to' f)@
+-- @
+-- 'views' l f ≡ 'view' (l '.' 'to' f)
+-- @
--
-- >>> views (to f) g a
-- g (f a)
@@ -214,7 +222,9 @@ view l = Reader.asks (runAccessor #. l Accessor)
-- 'view' :: ('MonadReader' s m, 'Data.Monoid.Monoid' a) => 'Control.Lens.Traversal.Traversal'' s a -> m a
-- @
--
--- @'views' :: 'MonadReader' s m => 'Getting' r s t a b -> (a -> r) -> m r@
+-- @
+-- 'views' :: 'MonadReader' s m => 'Getting' r s t a b -> (a -> r) -> m r
+-- @
views :: (Profunctor p, MonadReader s m) => Overloading p (->) (Accessor r) s t a b -> p a r -> m r
views l f = Reader.asks (runAccessor #. l (rmap Accessor f))
{-# INLINE views #-}
@@ -291,7 +301,9 @@ use l = State.gets (view l)
-- 'uses' :: ('MonadState' s m, 'Data.Monoid.Monoid' r) => 'Control.Lens.Traversal.Traversal'' s a -> (a -> r) -> m r
-- @
--
--- @'uses' :: 'MonadState' s m => 'Getting' r s t a b -> (a -> r) -> m r@
+-- @
+-- 'uses' :: 'MonadState' s m => 'Getting' r s t a b -> (a -> r) -> m r
+-- @
uses :: (Profunctor p, MonadState s m) => Overloading p (->) (Accessor r) s t a b -> p a r -> m r
uses l f = State.gets (views l f)
{-# INLINE uses #-}
@@ -420,7 +432,9 @@ use' l = State.gets (view' l)
-- 'uses'' :: ('MonadState' s m, 'Data.Monoid.Monoid' r) => 'Control.Lens.Traversal.Traversal'' s a -> (a -> r) -> m r
-- @
--
--- @'uses'' :: 'MonadState' s m => 'Getting' r s s a a -> (a -> r) -> m r@
+-- @
+-- 'uses'' :: 'MonadState' s m => 'Getting' r s s a a -> (a -> r) -> m r
+-- @
uses' :: (Profunctor p, MonadState s m) => Overloading' p (->) (Accessor r) s a -> p a r -> m r
uses' l f = State.gets (views' l f)
{-# INLINE uses' #-}
@@ -436,7 +450,9 @@ uses' l f = State.gets (views' l f)
-- 'Control.Lens.Fold.Fold' or 'Control.Lens.Traversal.Traversal' that points
-- at a monoidal values.
--
--- @'view'' '.' 'to' ≡ 'id'@
+-- @
+-- 'view'' '.' 'to' ≡ 'id'
+-- @
--
-- >>> view' (to f) a
-- f a
@@ -481,7 +497,9 @@ view' l = Reader.asks (runAccessor #. l Accessor)
-- the targets of a 'Control.Lens.Fold.Fold' or
-- 'Control.Lens.Traversal.Traversal'.
--
--- @'views'' l f ≡ 'view'' (l '.' 'to' f)@
+-- @
+-- 'views'' l f ≡ 'view'' (l '.' 'to' f)
+-- @
--
-- >>> views' _2 length (1,"hello")
-- 5
@@ -507,7 +525,9 @@ view' l = Reader.asks (runAccessor #. l Accessor)
-- 'views'' :: ('MonadReader' s m, 'Data.Monoid.Monoid' a) => 'Control.Lens.Traversal.Traversal'' s a -> (a -> r) -> m r
-- @
--
--- @'views'' :: 'MonadReader' s m => 'Getting' r s s a a -> (a -> r) -> m r@
+-- @
+-- 'views'' :: 'MonadReader' s m => 'Getting' r s s a a -> (a -> r) -> m r
+-- @
views' :: (Profunctor p, MonadReader s m) => Overloading' p (->) (Accessor r) s a -> p a r -> m r
views' l f = Reader.asks (runAccessor #. l (rmap Accessor f))
{-# INLINE views' #-}
@@ -528,7 +548,9 @@ iview l = asks (runAccessor #. l (Indexed $ \i -> Accessor #. (,) i))
--
-- When applied to an 'IndexedFold' the result will be a monoidal summary instead of a single answer.
--
--- @'iviews' ≡ 'Control.Lens.Fold.ifoldMapOf'@
+-- @
+-- 'iviews' ≡ 'Control.Lens.Fold.ifoldMapOf'
+-- @
iviews :: MonadReader s m => IndexedGetting i r s t a b -> (i -> a -> r) -> m r
iviews l = views l .# Indexed
{-# INLINE iviews #-}
80 src/Control/Lens/Indexed.hs
View
@@ -228,7 +228,9 @@ class Foldable f => FoldableWithIndex i f | f -> i where
--
-- When you don't need access to the index then 'foldMap' is more flexible in what it accepts.
--
- -- @'foldMap' ≡ 'ifoldMap' '.' 'const'@
+ -- @
+ -- 'foldMap' ≡ 'ifoldMap' '.' 'const'
+ -- @
ifoldMap :: Monoid m => (i -> a -> m) -> f a -> m
#ifdef MPTC_DEFAULTS
default ifoldMap :: (TraversableWithIndex i f, Monoid m) => (i -> a -> m) -> f a -> m
@@ -240,7 +242,9 @@ class Foldable f => FoldableWithIndex i f | f -> i where
--
-- When you don't need access to the index then 'Data.Foldable.foldr' is more flexible in what it accepts.
--
- -- @'Data.Foldable.foldr' ≡ 'ifoldr' '.' 'const'@
+ -- @
+ -- 'Data.Foldable.foldr' ≡ 'ifoldr' '.' 'const'
+ -- @
ifoldr :: (i -> a -> b -> b) -> b -> f a -> b
ifoldr f z t = appEndo (ifoldMap (\i -> Endo #. f i) t) z
@@ -248,7 +252,9 @@ class Foldable f => FoldableWithIndex i f | f -> i where
--
-- When you don't need access to the index then 'Data.Foldable.foldl' is more flexible in what it accepts.
--
- -- @'Data.Foldable.foldl' ≡ 'ifoldl' '.' 'const'@
+ -- @
+ -- 'Data.Foldable.foldl' ≡ 'ifoldl' '.' 'const'
+ -- @
ifoldl :: (i -> b -> a -> b) -> b -> f a -> b
ifoldl f z t = appEndo (getDual (ifoldMap (\i -> Dual #. Endo #. flip (f i)) t)) z
@@ -256,7 +262,9 @@ class Foldable f => FoldableWithIndex i f | f -> i where
--
-- When you don't need access to the index then 'foldr'' is more flexible in what it accepts.
--
- -- @'foldr'' ≡ 'ifoldr'' '.' 'const'@
+ -- @
+ -- 'foldr'' ≡ 'ifoldr'' '.' 'const'
+ -- @
ifoldr' :: (i -> a -> b -> b) -> b -> f a -> b
ifoldr' f z0 xs = ifoldl f' id xs z0
where f' i k x z = k $! f i x z
@@ -265,7 +273,9 @@ class Foldable f => FoldableWithIndex i f | f -> i where
--
-- When you don't need access to the index then 'Control.Lens.Fold.foldlOf'' is more flexible in what it accepts.
--
- -- @'Control.Lens.Fold.foldlOf'' l ≡ 'ifoldlOf'' l '.' 'const'@
+ -- @
+ -- 'Control.Lens.Fold.foldlOf'' l ≡ 'ifoldlOf'' l '.' 'const'
+ -- @
ifoldl' :: (i -> b -> a -> b) -> b -> f a -> b
ifoldl' f z0 xs = ifoldr f' id xs z0
where f' i x k z = k $! f i z x
@@ -286,7 +296,9 @@ ifolding sfa iagb = coerce . itraverse_ (indexed iagb) . sfa
--
-- When you don't need access to the index then 'any' is more flexible in what it accepts.
--
--- @'any' ≡ 'iany' '.' 'const'@
+-- @
+-- 'any' ≡ 'iany' '.' 'const'
+-- @
iany :: FoldableWithIndex i f => (i -> a -> Bool) -> f a -> Bool
iany f = getAny #. ifoldMap (\i -> Any #. f i)
{-# INLINE iany #-}
@@ -295,7 +307,9 @@ iany f = getAny #. ifoldMap (\i -> Any #. f i)
--
-- When you don't need access to the index then 'all' is more flexible in what it accepts.
--
--- @'all' ≡ 'iall' '.' 'const'@
+-- @
+-- 'all' ≡ 'iall' '.' 'const'
+-- @
iall :: FoldableWithIndex i f => (i -> a -> Bool) -> f a -> Bool
iall f = getAll #. ifoldMap (\i -> All #. f i)
{-# INLINE iall #-}
@@ -304,18 +318,24 @@ iall f = getAll #. ifoldMap (\i -> All #. f i)
--
-- When you don't need access to the index then 'traverse_' is more flexible in what it accepts.
--
--- @'traverse_' l = 'itraverse' '.' 'const'@
+-- @
+-- 'traverse_' l = 'itraverse' '.' 'const'
+-- @
itraverse_ :: (FoldableWithIndex i t, Applicative f) => (i -> a -> f b) -> t a -> f ()
itraverse_ f = getTraversed #. ifoldMap (\i -> Traversed #. void . f i)
{-# INLINE itraverse_ #-}
-- | Traverse elements with access to the index @i@, discarding the results (with the arguments flipped).
--
--- @'ifor_' ≡ 'flip' 'itraverse_'@
+-- @
+-- 'ifor_' ≡ 'flip' 'itraverse_'
+-- @
--
-- When you don't need access to the index then 'for_' is more flexible in what it accepts.
--
--- @'for_' a ≡ 'ifor_' a '.' 'const'@
+-- @
+-- 'for_' a ≡ 'ifor_' a '.' 'const'
+-- @
ifor_ :: (FoldableWithIndex i t, Applicative f) => t a -> (i -> a -> f b) -> f ()
ifor_ = flip itraverse_
{-# INLINE ifor_ #-}
@@ -325,7 +345,9 @@ ifor_ = flip itraverse_
--
-- When you don't need access to the index then 'Control.Lens.Fold.mapMOf_' is more flexible in what it accepts.
--
--- @'mapM_' ≡ 'imapM' '.' 'const'@
+-- @
+-- 'mapM_' ≡ 'imapM' '.' 'const'
+-- @
imapM_ :: (FoldableWithIndex i t, Monad m) => (i -> a -> m b) -> t a -> m ()
imapM_ f = getSequenced #. ifoldMap (\i -> Sequenced #. liftM skip . f i)
{-# INLINE imapM_ #-}
@@ -333,11 +355,15 @@ imapM_ f = getSequenced #. ifoldMap (\i -> Sequenced #. liftM skip . f i)
-- | Run monadic actions for each target of an 'IndexedFold' or 'Control.Lens.IndexedTraversal.IndexedTraversal' with access to the index,
-- discarding the results (with the arguments flipped).
--
--- @'iforM_' ≡ 'flip' 'imapM_'@
+-- @
+-- 'iforM_' ≡ 'flip' 'imapM_'
+-- @
--
-- When you don't need access to the index then 'Control.Lens.Fold.forMOf_' is more flexible in what it accepts.
--
--- @'Control.Lens.Fold.forMOf_' l a ≡ 'iforMOf' l a '.' 'const'@
+-- @
+-- 'Control.Lens.Fold.forMOf_' l a ≡ 'iforMOf' l a '.' 'const'
+-- @
iforM_ :: (FoldableWithIndex i t, Monad m) => t a -> (i -> a -> m b) -> m ()
iforM_ = flip imapM_
{-# INLINE iforM_ #-}
@@ -359,7 +385,9 @@ iconcatMap = ifoldMap
--
-- When you don't need access to the index then 'find' is more flexible in what it accepts.
--
--- @'find' ≡ 'ifind' '.' 'const'@
+-- @
+-- 'find' ≡ 'ifind' '.' 'const'
+-- @
ifind :: FoldableWithIndex i f => (i -> a -> Bool) -> f a -> Maybe (i, a)
ifind p = ifoldr (\i a y -> if p i a then Just (i, a) else y) Nothing
{-# INLINE ifind #-}
@@ -368,7 +396,9 @@ ifind p = ifoldr (\i a y -> if p i a then Just (i, a) else y) Nothing
--
-- When you don't need access to the index then 'foldrM' is more flexible in what it accepts.
--
--- @'foldrM' ≡ 'ifoldrM' '.' 'const'@
+-- @
+-- 'foldrM' ≡ 'ifoldrM' '.' 'const'
+-- @
ifoldrM :: (FoldableWithIndex i f, Monad m) => (i -> a -> b -> m b) -> b -> f a -> m b
ifoldrM f z0 xs = ifoldl f' return xs z0
where f' i k x z = f i x z >>= k
@@ -378,7 +408,9 @@ ifoldrM f z0 xs = ifoldl f' return xs z0
--
-- When you don't need access to the index then 'foldlM' is more flexible in what it accepts.
--
--- @'foldlM' ≡ 'ifoldlM' '.' 'const'@
+-- @
+-- 'foldlM' ≡ 'ifoldlM' '.' 'const'
+-- @
ifoldlM :: (FoldableWithIndex i f, Monad m) => (i -> b -> a -> m b) -> b -> f a -> m b
ifoldlM f z0 xs = ifoldr f' return xs z0
where f' i x k z = f i z x >>= k
@@ -388,7 +420,9 @@ ifoldlM f z0 xs = ifoldr f' return xs z0
--
-- When you don't need access to the indices in the result, then 'Data.Foldable.toList' is more flexible in what it accepts.
--
--- @'Data.Foldable.toList' ≡ 'Data.List.map' 'fst' '.' 'itoList'@
+-- @
+-- 'Data.Foldable.toList' ≡ 'Data.List.map' 'fst' '.' 'itoList'
+-- @
itoList :: FoldableWithIndex i f => f a -> [(i,a)]
itoList = ifoldr (\i c -> ((i,c):)) []
{-# INLINE itoList #-}
@@ -435,7 +469,9 @@ ifor = flip itraverse
--
-- When you don't need access to the index 'mapM' is more liberal in what it can accept.
--
--- @'mapM' ≡ 'imapM' '.' 'const'@
+-- @
+-- 'mapM' ≡ 'imapM' '.' 'const'
+-- @
imapM :: (TraversableWithIndex i t, Monad m) => (i -> a -> m b) -> t a -> m (t b)
imapM f = unwrapMonad #. itraverse (\i -> WrapMonad #. f i)
{-# INLINE imapM #-}
@@ -456,7 +492,9 @@ iforM = flip imapM
--
-- 'imapAccumROf' accumulates state from right to left.
--
--- @'Control.Lens.Traversal.mapAccumR' ≡ 'imapAccumR' '.' 'const'@
+-- @
+-- 'Control.Lens.Traversal.mapAccumR' ≡ 'imapAccumR' '.' 'const'
+-- @
imapAccumR :: TraversableWithIndex i t => (i -> s -> a -> (s, b)) -> s -> t a -> (s, t b)
imapAccumR f s0 a = swap (Lazy.runState (forwards (itraverse (\i c -> Backwards (Lazy.state (\s -> swap (f i s c)))) a)) s0)
{-# INLINE imapAccumR #-}
@@ -465,7 +503,9 @@ imapAccumR f s0 a = swap (Lazy.runState (forwards (itraverse (\i c -> Backwards
--
-- 'imapAccumLOf' accumulates state from left to right.
--
--- @'Control.Lens.Traversal.mapAccumLOf' ≡ 'imapAccumL' '.' 'const'@
+-- @
+-- 'Control.Lens.Traversal.mapAccumLOf' ≡ 'imapAccumL' '.' 'const'
+-- @
imapAccumL :: TraversableWithIndex i t => (i -> s -> a -> (s, b)) -> s -> t a -> (s, t b)
imapAccumL f s0 a = swap (Lazy.runState (itraverse (\i c -> Lazy.state (\s -> swap (f i s c))) a) s0)
{-# INLINE imapAccumL #-}
4 src/Control/Lens/Internal/Zipper.hs
View
@@ -340,7 +340,9 @@ infixl 8 :>
-- abstracting over the position and the index, in terms of ':@'. You
-- can visually see it in type signatures as:
--
--- @h ':>' (a ':@' i) = 'Zipper' h i a@
+-- @
+-- h ':>' (a ':@' i) = 'Zipper' h i a
+-- @
--
type family (:>) h p
type instance h :> (a :@ i) = Zipper h i a
24 src/Control/Lens/Iso.hs
View
@@ -107,7 +107,9 @@ iso sa bt = dimap sa (fmap bt)
-- | Invert an isomorphism.
--
--- @'from' ('from' l) ≡ l@
+-- @
+-- 'from' ('from' l) ≡ l
+-- @
from :: AnIso s t a b -> Iso b a t s
from k = case runIso k of
Exchange sa bt -> iso bt sa
@@ -167,9 +169,13 @@ auf k = case runIso k of
-- | The opposite of working 'Control.Lens.Setter.over' a 'Setter' is working 'under' an isomorphism.
--
--- @'under' ≡ 'Control.Lens.Setter.over' '.' 'from'@
+-- @
+-- 'under' ≡ 'Control.Lens.Setter.over' '.' 'from'
+-- @
--
--- @'under' :: 'Iso' s t a b -> (s -> t) -> a -> b@
+-- @
+-- 'under' :: 'Iso' s t a b -> (s -> t) -> a -> b
+-- @
under :: AnIso s t a b -> (t -> s) -> b -> a
under k = case runIso k of
Exchange sa bt -> \ts -> sa . ts . bt
@@ -262,16 +268,22 @@ anon a p = iso (fromMaybe a) go where
-- | The canonical isomorphism for currying and uncurrying a function.
--
--- @'curried' = 'iso' 'curry' 'uncurry'@
+-- @
+-- 'curried' = 'iso' 'curry' 'uncurry'
+-- @
curried :: Iso ((a,b) -> c) ((d,e) -> f) (a -> b -> c) (d -> e -> f)
curried = iso curry uncurry
{-# INLINE curried #-}
-- | The canonical isomorphism for uncurrying and currying a function.
--
--- @'uncurried' = 'iso' 'uncurry' 'curry'@
+-- @
+-- 'uncurried' = 'iso' 'uncurry' 'curry'
+-- @
--
--- @'uncurried' = 'from' 'curried'@
+-- @
+-- 'uncurried' = 'from' 'curried'
+-- @
uncurried :: Iso (a -> b -> c) (d -> e -> f) ((a,b) -> c) ((d,e) -> f)
uncurried = iso uncurry curry
{-# INLINE uncurried #-}
10 src/Control/Lens/Lens.hs
View
@@ -30,7 +30,9 @@
--
-- 'Functor', however is the superclass of both.
--
--- @type 'Lens' s t a b = forall f. 'Functor' f => (a -> f b) -> s -> f t@
+-- @
+-- type 'Lens' s t a b = forall f. 'Functor' f => (a -> f b) -> s -> f t
+-- @
--
-- Every 'Lens' is a valid 'Control.Lens.Setter.Setter'.
--
@@ -146,8 +148,7 @@ infixr 2 <<~
-- or use it directly with combinators like 'storing' and ('^#').
type ALens s t a b = LensLike (Pretext (->) a b) s t a b
--- |
--- @
+-- | @
-- type 'ALens'' = 'Simple' 'ALens'
-- @
type ALens' s a = ALens s s a a
@@ -155,8 +156,7 @@ type ALens' s a = ALens s s a a
-- | When you see this as an argument to a function, it expects an 'IndexedLens'
type AnIndexedLens i s t a b = Overloading (Indexed i) (->) (Pretext (Indexed i) a b) s t a b
--- |
--- @
+-- | @
-- type 'AnIndexedLens'' = 'Simple' ('AnIndexedLens' i)
-- @
type AnIndexedLens' i s a = AnIndexedLens i s s a a
4 src/Control/Lens/Loupe.hs
View
@@ -34,7 +34,9 @@ import Control.Lens.Type
type Loupe s t a b = LensLike (Pretext (->) a b) s t a b
{-# DEPRECATED Loupe "use ALens" #-}
--- | @type 'SimpleLoupe' = 'Simple' 'Loupe'@
+-- | @
+-- type 'SimpleLoupe' = 'Simple' 'Loupe'
+-- @
--
-- Deprecated for two reasons. 'Loupe' is now 'ALens', and we no longer use the verbose @SimpleFoo@ naming
-- convention, this has since been renamed to 'ALens'' for consistency.
94 src/Control/Lens/Plated.hs
View
@@ -174,7 +174,9 @@ import Data.Tree
-- use the @...OnOf@ variant with 'ignored', though those usecases are much better served
-- in most cases by using the existing 'Lens' combinators! e.g.
--
--- @'toListOf' 'biplate' ≡ 'universeOnOf' 'biplate' 'ignored'@.
+-- @
+-- 'toListOf' 'biplate' ≡ 'universeOnOf' 'biplate' 'ignored'
+-- @
--
-- This same ability to explicitly pass the 'Traversal' in question is why there is no
-- analogue to uniplate's @Biplate@.
@@ -218,7 +220,9 @@ instance Plated TH.Pat where plate = uniplate
-- | Extract the immediate descendants of a 'Plated' container.
--
--- @'children' ≡ 'toListOf' 'plate'@
+-- @
+-- 'children' ≡ 'toListOf' 'plate'
+-- @
children :: Plated a => a -> [a]
children = toListOf plate
{-# INLINE children #-}
@@ -230,7 +234,9 @@ children = toListOf plate
-- | Rewrite by applying a rule everywhere you can. Ensures that the rule cannot
-- be applied anywhere in the result:
--
--- @propRewrite r x = 'all' ('Data.Just.isNothing' '.' r) ('universe' ('rewrite' r x))@
+-- @
+-- propRewrite r x = 'all' ('Data.Just.isNothing' '.' r) ('universe' ('rewrite' r x))
+-- @
--
-- Usually 'transform' is more appropriate, but 'rewrite' can give better
-- compositionality. Given two single transformations @f@ and @g@, you can
@@ -242,7 +248,9 @@ rewrite = rewriteOf plate
-- | Rewrite by applying a rule everywhere you can. Ensures that the rule cannot
-- be applied anywhere in the result:
--
--- @propRewriteOf l r x = 'all' ('Data.Just.isNothing' '.' r) ('universeOf' l ('rewriteOf' l r x))@
+-- @
+-- propRewriteOf l r x = 'all' ('Data.Just.isNothing' '.' r) ('universeOf' l ('rewriteOf' l r x))
+-- @
--
-- Usually 'transformOf' is more appropriate, but 'rewriteOf' can give better
-- compositionality. Given two single transformations @f@ and @g@, you can
@@ -319,7 +327,9 @@ universe = universeOf plate
-- | Given a 'Fold' that knows how to locate immediate children, retrieve all of the transitive descendants of a node, including itself.
--
--- @'universeOf' :: 'Fold' a a -> a -> [a]@
+-- @
+-- 'universeOf' :: 'Fold' a a -> a -> [a]
+-- @
universeOf :: Getting [a] a b a b -> a -> [a]
universeOf l = go where
go a = a : foldMapOf l go a
@@ -333,7 +343,9 @@ universeOn b = universeOnOf b plate
-- | Given a 'Fold' that knows how to locate immediate children, retrieve all of the transitive descendants of a node, including itself that lie
-- in a region indicated by another 'Fold'.
--
--- @'toListOf' l ≡ 'universeOnOf' l 'ignored'@
+-- @
+-- 'toListOf' l ≡ 'universeOnOf' l 'ignored'
+-- @
universeOnOf :: Getting [a] s t a b -> Getting [a] a b a b -> s -> [a]
universeOnOf b = foldMapOf b . universeOf
{-# INLINE universeOnOf #-}
@@ -394,14 +406,18 @@ transformM = transformMOf plate
-- | Transform every element in the tree in a region indicated by a supplied 'Traversal', in a bottom-up manner, monadically.
--
--- @'transformMOn' :: ('Monad' m, 'Plated' a) => 'Traversal'' s a -> (a -> m a) -> s -> m s@
+-- @
+-- 'transformMOn' :: ('Monad' m, 'Plated' a) => 'Traversal'' s a -> (a -> m a) -> s -> m s
+-- @
transformMOn :: (Monad m, Plated a) => LensLike (WrappedMonad m) s t a a -> (a -> m a) -> s -> m t
transformMOn b = mapMOf b . transformM
{-# INLINE transformMOn #-}
-- | Transform every element in a tree using a user supplied 'Traversal' in a bottom-up manner with a monadic effect.
--
--- @'transformMOf' :: 'Monad' m => 'Traversal'' a a -> (a -> m a) -> a -> m a@
+-- @
+-- 'transformMOf' :: 'Monad' m => 'Traversal'' a a -> (a -> m a) -> a -> m a
+-- @
transformMOf :: Monad m => LensLike' (WrappedMonad m) a a -> (a -> m a) -> a -> m a
transformMOf l f = go where
go t = mapMOf l go t >>= f
@@ -410,7 +426,9 @@ transformMOf l f = go where
-- | Transform every element in a tree that lies in a region indicated by a supplied 'Traversal', walking with a user supplied 'Traversal' in
-- a bottom-up manner with a monadic effect.
--
--- @'transformMOnOf' :: 'Monad' m => 'Traversal'' s a -> 'Traversal'' a a -> (a -> m a) -> s -> m s@
+-- @
+-- 'transformMOnOf' :: 'Monad' m => 'Traversal'' s a -> 'Traversal'' a a -> (a -> m a) -> s -> m s
+-- @
transformMOnOf :: Monad m => LensLike (WrappedMonad m) s a a a -> LensLike' (WrappedMonad m) a a -> (a -> m a) -> s -> m a
transformMOnOf b l = mapMOf b . transformMOf l
{-# INLINE transformMOnOf #-}
@@ -423,10 +441,12 @@ transformMOnOf b l = mapMOf b . transformMOf l
--
-- @
-- propUniverse x = 'universe' x '==' 'map' 'Control.Comonad.Store.Class.pos' ('contexts' x)
--- propId x = 'all' ('==' x) ['extract' w | w <- 'contexts' x]
+-- propId x = 'all' ('==' x) ['Control.Lens.Internal.Context.extract' w | w <- 'contexts' x]
-- @
--
--- @'contexts' ≡ 'contextsOf' 'plate'@
+-- @
+-- 'contexts' ≡ 'contextsOf' 'plate'
+-- @
contexts :: Plated a => a -> [Context a a a]
contexts = contextsOf plate
{-# INLINE contexts #-}
@@ -434,11 +454,13 @@ contexts = contextsOf plate
-- | Return a list of all of the editable contexts for every location in the structure, recursively, using a user-specified 'Traversal' to walk each layer.
--
-- @
--- propUniverse l x = 'universeOf' l x == 'map' 'Control.Comonad.Store.Class.pos' ('contextsOf' l x)
--- propId l x = 'all' ('==' x) ['extract' w | w <- 'contextsOf' l x]
+-- propUniverse l x = 'universeOf' l x '==' 'map' 'Control.Comonad.Store.Class.pos' ('contextsOf' l x)
+-- propId l x = 'all' ('==' x) ['Control.Lens.Internal.Context.extract' w | w <- 'contextsOf' l x]
-- @
--
--- @'contextsOf' :: 'Traversal'' a a -> a -> ['Context' a a]@
+-- @
+-- 'contextsOf' :: 'Traversal'' a a -> a -> ['Context' a a]
+-- @
contextsOf :: ATraversal' a a -> a -> [Context a a a]
contextsOf l x = sell x : f (map context (holesOf l x)) where
f xs = do
@@ -449,9 +471,13 @@ contextsOf l x = sell x : f (map context (holesOf l x)) where
-- | Return a list of all of the editable contexts for every location in the structure in an areas indicated by a user supplied 'Traversal', recursively using 'plate'.
--
--- @'contextsOn' b ≡ 'contextsOnOf' b 'plate'@
+-- @
+-- 'contextsOn' b ≡ 'contextsOnOf' b 'plate'
+-- @
--
--- @'contextsOn' :: 'Plated' a => 'Traversal'' s a -> s -> ['Context' a a s]@
+-- @
+-- 'contextsOn' :: 'Plated' a => 'Traversal'' s a -> s -> ['Context' a a s]
+-- @
contextsOn :: Plated a => ATraversal s t a a -> s -> [Context a a t]
contextsOn b = contextsOnOf b plate
{-# INLINE contextsOn #-}
@@ -459,7 +485,9 @@ contextsOn b = contextsOnOf b plate
-- | Return a list of all of the editable contexts for every location in the structure in an areas indicated by a user supplied 'Traversal', recursively using
-- another user-supplied 'Traversal' to walk each layer.
--
--- @'contextsOnOf' :: 'Traversal'' s a -> 'Traversal'' a a -> s -> ['Context' a a s]@
+-- @
+-- 'contextsOnOf' :: 'Traversal'' s a -> 'Traversal'' a a -> s -> ['Context' a a s]
+-- @
contextsOnOf :: ATraversal s t a a -> ATraversal' a a -> s -> [Context a a t]
contextsOnOf b l = f . map context . holesOf b where
f xs = do
@@ -470,21 +498,25 @@ contextsOnOf b l = f . map context . holesOf b where
-- | The one-level version of 'context'. This extracts a list of the immediate children as editable contexts.
--
--- Given a context you can use 'Control.Comonad.Store.Class.pos' to see the values, 'Control.Comonad.Store.Class.peek' at what the structure would be like with an edited result, or simply 'extract' the original structure.
+-- Given a context you can use 'Control.Comonad.Store.Class.pos' to see the values, 'Control.Comonad.Store.Class.peek' at what the structure would be like with an edited result, or simply 'Control.Lens.Internal.Context.extract' the original structure.
--
-- @
-- propChildren x = 'children' l x '==' 'map' 'Control.Comonad.Store.Class.pos' ('holes' l x)
--- propId x = 'all' ('==' x) ['extract' w | w <- 'holes' l x]
+-- propId x = 'all' ('==' x) ['Control.Lens.Internal.Context.extract' w | w <- 'holes' l x]
-- @
--
--- @'holes' = 'holesOf' 'plate'@
+-- @
+-- 'holes' = 'holesOf' 'plate'
+-- @
holes :: Plated a => a -> [Pretext (->) a a a]
holes = holesOf plate
{-# INLINE holes #-}
-- | An alias for 'holesOf', provided for consistency with the other combinators.
--
--- @'holesOn' ≡ 'holesOf'@
+-- @
+-- 'holesOn' ≡ 'holesOf'
+-- @
--
-- @
-- 'holesOn' :: 'Iso'' s a -> s -> ['Pretext' (->) a a s]
@@ -499,7 +531,9 @@ holesOn = holesOf
-- | Extract one level of 'holes' from a container in a region specified by one 'Traversal', using another.
--
--- @'holesOnOf' b l ≡ 'holesOf' (b '.' l)@
+-- @
+-- 'holesOnOf' b l ≡ 'holesOf' (b '.' l)
+-- @
--
-- @
-- 'holesOnOf' :: 'Iso'' s a -> 'Iso'' a a -> s -> ['Pretext' (->) a a s]
@@ -521,7 +555,9 @@ holesOnOf b l = holesOf (b . l)
-- | Perform a fold-like computation on each value, technically a paramorphism.
--
--- @'paraOf' :: 'Fold' a a -> (a -> [r] -> r) -> a -> r@
+-- @
+-- 'paraOf' :: 'Fold' a a -> (a -> [r] -> r) -> a -> r
+-- @
paraOf :: Getting (Endo [a]) a b a b -> (a -> [r] -> r) -> a -> r
paraOf l f = go where
go a = f a (go <$> toListOf l a)
@@ -529,7 +565,9 @@ paraOf l f = go where
-- | Perform a fold-like computation on each value, technically a paramorphism.
--
--- @'para' ≡ 'paraOf' 'plate'@
+-- @
+-- 'para' ≡ 'paraOf' 'plate'
+-- @
para :: Plated a => (a -> [r] -> r) -> a -> r
para = paraOf plate
{-# INLINE para #-}
@@ -555,7 +593,9 @@ para = paraOf plate
-- | Fold the immediate children of a 'Plated' container.
--
--- @'composOpFold' z c f = 'foldrOf' 'plate' (c '.' f) z@
+-- @
+-- 'composOpFold' z c f = 'foldrOf' 'plate' (c '.' f) z
+-- @
composOpFold :: Plated a => b -> (b -> b -> b) -> (a -> b) -> a -> b
composOpFold z c f = foldrOf plate (c . f) z
{-# INLINE composOpFold #-}
@@ -566,7 +606,9 @@ composOpFold z c f = foldrOf plate (c . f) z
-- | The original @uniplate@ combinator, implemented in terms of 'Plated' as a 'Lens'.
--
--- @'parts' ≡ 'partsOf' 'plate'@
+-- @
+-- 'parts' ≡ 'partsOf' 'plate'
+-- @
--
-- The resulting 'Lens' is safer to use as it ignores 'over-application' and deals gracefully with under-application,
-- but it is only a proper 'Lens' if you don't change the list 'length'!
32 src/Control/Lens/Reified.hs
View
@@ -20,25 +20,33 @@ import Control.Lens.Type
-- | Reify a 'Lens' so it can be stored safely in a container.
newtype ReifiedLens s t a b = ReifyLens { reflectLens :: Lens s t a b }
--- | @type 'ReifiedLens'' = 'Simple' 'ReifiedLens'@
+-- | @
+-- type 'ReifiedLens'' = 'Simple' 'ReifiedLens'
+-- @
type ReifiedLens' s a = ReifiedLens s s a a
-- | Reify an 'IndexedLens' so it can be stored safely in a container.
newtype ReifiedIndexedLens i s t a b = ReifyIndexedLens { reflectIndexedLens :: IndexedLens i s t a b }
--- | @type 'ReifiedIndexedLens'' i = 'Simple' ('ReifiedIndexedLens' i)@
+-- | @
+-- type 'ReifiedIndexedLens'' i = 'Simple' ('ReifiedIndexedLens' i)
+-- @
type ReifiedIndexedLens' i s a = ReifiedIndexedLens i s s a a
-- | Reify an 'IndexedTraversal' so it can be stored safely in a container.
newtype ReifiedIndexedTraversal i s t a b = ReifyIndexedTraversal { reflectIndexedTraversal :: IndexedTraversal i s t a b }
--- | @type 'ReifiedIndexedTraversal'' i = 'Simple' ('ReifiedIndexedTraversal' i)@
+-- | @
+-- type 'ReifiedIndexedTraversal'' i = 'Simple' ('ReifiedIndexedTraversal' i)
+-- @
type ReifiedIndexedTraversal' i s a = ReifiedIndexedTraversal i s s a a
-- | A form of 'Traversal' that can be stored monomorphically in a container.
data ReifiedTraversal s t a b = ReifyTraversal { reflectTraversal :: Traversal s t a b }
--- | @type 'ReifiedTraversal'' = 'Simple' 'ReifiedTraversal'@
+-- | @
+-- type 'ReifiedTraversal'' = 'Simple' 'ReifiedTraversal'
+-- @
type ReifiedTraversal' s a = ReifiedTraversal s s a a
-- | Reify a 'Getter' so it can be stored safely in a container.
@@ -53,24 +61,32 @@ newtype ReifiedFold s a = ReifyFold { reflectFold :: Fold s a }
-- | Reify a 'Setter' so it can be stored safely in a container.
newtype ReifiedSetter s t a b = ReifySetter { reflectSetter :: Setter s t a b }
--- | @type 'ReifiedSetter'' = 'Simple' 'ReifiedSetter'@
+-- | @
+-- type 'ReifiedSetter'' = 'Simple' 'ReifiedSetter'
+-- @
type ReifiedSetter' s a = ReifiedSetter s s a a
-- | Reify an 'IndexedSetter' so it can be stored safely in a container.
newtype ReifiedIndexedSetter i s t a b =
ReifyIndexedSetter { reflectIndexedSetter :: IndexedSetter i s t a b }
--- | @type 'ReifiedIndexedSetter'' i = 'Simple' ('ReifiedIndexedSetter' i)@
+-- | @
+-- type 'ReifiedIndexedSetter'' i = 'Simple' ('ReifiedIndexedSetter' i)
+-- @
type ReifiedIndexedSetter' i s a = ReifiedIndexedSetter i s s a a
-- | Reify an 'Iso' so it can be stored safely in a container.
newtype ReifiedIso s t a b = ReifyIso { reflectIso :: Iso s t a b }
--- | @type 'ReifiedIso'' = 'Simple' 'ReifiedIso'@
+-- | @
+-- type 'ReifiedIso'' = 'Simple' 'ReifiedIso'
+-- @
type ReifiedIso' s a = ReifiedIso s s a a
-- | Reify a 'Prism' so it can be stored safely in a container.
newtype ReifiedPrism s t a b = ReifyPrism { reflectPrism :: Prism s t a b }
--- | @type 'ReifiedPrism'' = 'Simple' 'ReifiedPrism'@
+-- | @
+-- type 'ReifiedPrism'' = 'Simple' 'ReifiedPrism'
+-- @
type ReifiedPrism' s a = ReifiedPrism s s a a
14 src/Control/Lens/Review.hs
View
@@ -52,7 +52,7 @@ import Data.Profunctor.Unsafe
-- Like with a 'Getter', there are no laws to state for a 'Review'.
--
-- You can generate a 'Review' by using 'unto'. You can also use any 'Prism' or 'Iso'
--- directly as a 'Review'
+-- directly as a 'Review'.
type Review s t a b = forall p f. (Reviewable p, Settable f) => Overloaded p f s t a b
-- | A 'Simple' 'Review'
@@ -67,7 +67,9 @@ type AReview' t b = AReview t t b b
-- | An analogue of 'to' for 'review'.
--
--- @'unto' :: (b -> t) -> 'Review'' t b@
+-- @
+-- 'unto' :: (b -> t) -> 'Review'' t b
+-- @
unto :: (Reviewable p, Functor f) => (b -> t) -> Overloaded p f s t a b
unto f = retagged . rmap (fmap f)
@@ -96,7 +98,9 @@ re p = to (runIdentity #. runReviewed #. p .# Reviewed .# Identity)
-- | This can be used to turn an 'Control.Lens.Iso.Iso' or 'Prism' around and 'view' a value (or the current environment) through it the other way.
--
--- @'review' ≡ 'view' '.' 're'@
+-- @
+-- 'review' ≡ 'view' '.' 're'
+-- @
--
-- >>> review _Left "mustard"
-- Left "mustard"
@@ -123,7 +127,9 @@ review p = asks (runIdentity #. runReviewed #. p .# Reviewed .# Identity)
-- | This can be used to turn an 'Control.Lens.Iso.Iso' or 'Prism' around and 'view' a value (or the current environment) through it the other way,
-- applying a function.
--
--- @'reviews' ≡ 'views' '.' 're'@
+-- @
+-- 'reviews' ≡ 'views' '.' 're'
+-- @
--
-- >>> reviews _Left isRight "mustard"
-- False
80 src/Control/Lens/Setter.hs
View
@@ -20,7 +20,9 @@
-- enumerate those contents. Starting with @'fmap' :: 'Functor' f => (a -> b) -> f a -> f b@
-- we monomorphize the type to obtain @(a -> b) -> s -> t@ and then decorate it with 'Data.Functor.Identity.Identity' to obtain:
--
--- @type 'Setter' s t a b = (a -> 'Data.Functor.Identity.Identity' b) -> s -> 'Data.Functor.Identity.Identity' t@
+-- @
+-- type 'Setter' s t a b = (a -> 'Data.Functor.Identity.Identity' b) -> s -> 'Data.Functor.Identity.Identity' t
+-- @
--
-- Every 'Traversal' is a valid 'Setter', since 'Data.Functor.Identity.Identity' is 'Applicative'.
--
@@ -120,7 +122,9 @@ type ASetter s t a b = (a -> Mutator b) -> s -> Mutator t
--
-- Most user code will never have to use this type.
--
--- @type 'ASetter'' = 'Simple' 'ASetter'@
+-- @
+-- type 'ASetter'' = 'Simple' 'ASetter'
+-- @
type ASetter' s a = ASetter s s a a
-- | Running an 'IndexedSetter' instantiates it to a concrete type.
@@ -131,7 +135,9 @@ type ASetter' s a = ASetter s s a a
-- By choosing 'Mutator' rather than 'Data.Functor.Identity.Identity', we get nicer error messages.
type AnIndexedSetter i s t a b = Indexed i a (Mutator b) -> s -> Mutator t
--- | @type 'AnIndexedSetter'' i = 'Simple' ('AnIndexedSetter' i)@
+-- | @
+-- type 'AnIndexedSetter'' i = 'Simple' ('AnIndexedSetter' i)
+-- @
type AnIndexedSetter' i s a = AnIndexedSetter i s s a a
type Setting p s t a b = p a (Mutator b) -> s -> Mutator t
@@ -165,7 +171,9 @@ type Setting' p s a = Setting p s s a a
-- >>> over (mapped._2) length [("hello","world"),("leaders","!!!")]
-- [("hello",5),("leaders",3)]
--
--- @'mapped' :: 'Functor' f => 'Setter' (f a) (f b) a b@
+-- @
+-- 'mapped' :: 'Functor' f => 'Setter' (f a) (f b) a b
+-- @
--
-- If you want an 'IndexPreservingSetter' use @'setting' 'fmap'@.
mapped :: Functor f => Setter (f a) (f b) a b
@@ -177,7 +185,9 @@ mapped = sets fmap
-- You sometimes have to use this rather than 'mapped' -- due to
-- temporary insanity 'Functor' is not a superclass of 'Monad'.
--
--- @'liftM' ≡ 'over' 'lifted'@
+-- @
+-- 'liftM' ≡ 'over' 'lifted'
+-- @
--
-- >>> over lifted f [a,b,c]
-- [f a,f b,f c]
@@ -192,7 +202,9 @@ lifted = sets liftM
-- | This 'Setter' can be used to map over all of the inputs to a 'Contravariant'.
--
--- @'contramap' ≡ 'over' 'contramapped'@
+-- @
+-- 'contramap' ≡ 'over' 'contramapped'
+-- @
--
-- >>> getPredicate (over contramapped (*2) (Predicate even)) 5
-- True
@@ -226,7 +238,9 @@ contramapped = sets contramap
-- >>> (mapped.argument %~ f) h x y
-- h x (f y)
--
--- @'argument' :: 'Setter' (b -> r) (a -> r) a b@
+-- @
+-- 'argument' :: 'Setter' (b -> r) (a -> r) a b
+-- @
argument :: Profunctor p => Setter (p b r) (p a r) a b
argument = sets lmap
{-# INLINE argument #-}
@@ -250,14 +264,18 @@ argument = sets lmap
-- Another way to view 'sets' is that it takes a \"semantic editor combinator\"
-- and transforms it into a 'Setter'.
--
--- @'setting' :: ((a -> b) -> s -> t) -> 'Setter' s t a b@
+-- @
+-- 'setting' :: ((a -> b) -> s -> t) -> 'Setter' s t a b
+-- @
setting :: ((a -> b) -> s -> t) -> IndexPreservingSetter s t a b
setting l pafb = cotabulate $ \ws -> pure $ l (\a -> untainted (corep pafb (a <$ ws))) (extract ws)
{-# INLINE setting #-}
-- | Build a 'Setter', 'IndexedSetter' or 'IndexPreservingSetter' depending on your choice of 'Profunctor'.
--
--- @'sets' :: ((a -> b) -> s -> t) -> 'Setter' s t a b@
+-- @
+-- 'sets' :: ((a -> b) -> s -> t) -> 'Setter' s t a b
+-- @
sets :: (Profunctor p, Profunctor q, Settable f) => (p a b -> q s t) -> Overloading p q f s t a b
sets f g = taintedDot (f (untaintedDot g))
{-# INLINE sets #-}
@@ -294,7 +312,9 @@ cloneIndexedSetter l pafb = taintedDot (runMutator #. l (Indexed $ \i -> Mutator
--
-- Given any valid 'Setter' @l@, you can also rely on the law:
--
--- @'over' l f '.' 'over' l g = 'over' l (f '.' g)@
+-- @
+-- 'over' l f '.' 'over' l g = 'over' l (f '.' g)
+-- @
--
-- /e.g./
--
@@ -327,7 +347,9 @@ over l f = runMutator #. l (Mutator #. f)
-- | Replace the target of a 'Lens' or all of the targets of a 'Setter'
-- or 'Traversal' with a constant value.
--
--- @('<$') ≡ 'set' 'mapped'@
+-- @
+-- ('<$') ≡ 'set' 'mapped'
+-- @
--
-- >>> set _2 "hello" (1,())
-- (1,"hello")
@@ -418,7 +440,9 @@ set' l b = runMutator #. l (\_ -> Mutator b)
--
-- This is an infix version of 'set', provided for consistency with ('.=').
--
--- @f '<$' a ≡ 'mapped' '.~' f '$' a@
+-- @
+-- f '<$' a ≡ 'mapped' '.~' f '$' a
+-- @
--
-- >>> (a,b,c,d) & _4 .~ e
-- (a,b,c,e)
@@ -441,7 +465,9 @@ set' l b = runMutator #. l (\_ -> Mutator b)
-- | Set the target of a 'Lens', 'Traversal' or 'Setter' to 'Just' a value.
--
--- @l '?~' t ≡ 'set' l ('Just' t)@
+-- @
+-- l '?~' t ≡ 'set' l ('Just' t)
+-- @
--
-- >>> Nothing & id ?~ a
-- Just a
@@ -749,7 +775,9 @@ l .= b = State.modify (l .~ b)
-- ('%=') :: 'MonadState' s m => 'Setter'' s a -> (a -> a) -> m ()
-- @
--
--- @('%=') :: 'MonadState' s m => 'ASetter' s s a b -> (a -> b) -> m ()@
+-- @
+-- ('%=') :: 'MonadState' s m => 'ASetter' s s a b -> (a -> b) -> m ()
+-- @
(%=) :: (Profunctor p, MonadState s m) => Setting p s s a b -> p a b -> m ()
l %= f = State.modify (l %~ f)
{-# INLINE (%=) #-}
@@ -947,7 +975,9 @@ l <~ mb = mb >>= (l .=)
--
-- This is useful for chaining assignment without round-tripping through your 'Monad' stack.
--
--- @do x <- 'Control.Lens.Tuple._2' '<.=' ninety_nine_bottles_of_beer_on_the_wall@
+-- @
+-- do x <- 'Control.Lens.Tuple._2' '<.=' ninety_nine_bottles_of_beer_on_the_wall
+-- @
--
-- If you do not need a copy of the intermediate result, then using @l '.=' d@ will avoid unused binding warnings.
--
@@ -967,7 +997,9 @@ l <.= b = do
--
-- This is useful for chaining assignment without round-tripping through your 'Monad' stack.
--
--- @do x <- 'Control.Lens.At.at' "foo" '<?=' ninety_nine_bottles_of_beer_on_the_wall@
+-- @
+-- do x <- 'Control.Lens.At.at' "foo" '<?=' ninety_nine_bottles_of_beer_on_the_wall
+-- @
--
-- If you do not need a copy of the intermediate result, then using @l '?=' d@ will avoid unused binding warnings.
--
@@ -1109,11 +1141,15 @@ isets f = sets (f . indexed)
-- | Adjust every target of an 'IndexedSetter', 'IndexedLens' or 'IndexedTraversal'
-- with access to the index.
--
--- @('%@~') ≡ 'imapOf'@
+-- @
+-- ('%@~') ≡ 'imapOf'
+-- @
--
-- When you do not need access to the index then ('%@~') is more liberal in what it can accept.
--
--- @l '%~' f ≡ l '%@~' 'const' f@
+-- @
+-- l '%~' f ≡ l '%@~' 'const' f
+-- @
--
-- @
-- ('%@~') :: 'IndexedSetter' i s t a b -> (i -> a -> b) -> s -> t
@@ -1129,7 +1165,9 @@ l %@~ f = l %~ Indexed f
--
-- When you do not need access to the index then ('%=') is more liberal in what it can accept.
--
--- @l '%=' f ≡ l '%@=' 'const' f@
+-- @
+-- l '%=' f ≡ l '%@=' 'const' f
+-- @
--
-- @
-- ('%@=') :: 'MonadState' s m => 'IndexedSetter' i s s a b -> (i -> a -> b) -> m ()
@@ -1154,7 +1192,9 @@ mapOf = over
--
-- When you do not need access to the index, then 'mapOf' is more liberal in what it can accept.
--
--- @'mapOf' l ≡ 'imapOf' l '.' 'const'@
+-- @
+-- 'mapOf' l ≡ 'imapOf' l '.' 'const'
+-- @
--
-- @
-- 'imapOf' :: 'IndexedSetter' i s t a b -> (i -> a -> b) -> s -> t
20 src/Control/Lens/TH.hs
View
@@ -230,7 +230,9 @@ isoRules = defaultRules
-- | Build lenses (and traversals) with a sensible default configuration.
--
--- @'makeLenses' = 'makeLensesWith' 'lensRules'@
+-- @
+-- 'makeLenses' = 'makeLensesWith' 'lensRules'
+-- @
makeLenses :: Name -> Q [Dec]
makeLenses = makeLensesWith lensRules
@@ -253,7 +255,9 @@ makeLenses = makeLensesWith lensRules
-- fooX, fooY :: HasFoo t => 'Control.Lens.Type.Simple' 'Lens' t 'Int'
-- @
--
--- @'makeClassy' = 'makeLensesWith' 'classyRules'@
+-- @
+-- 'makeClassy' = 'makeLensesWith' 'classyRules'
+-- @
makeClassy :: Name -> Q [Dec]
makeClassy = makeLensesWith classyRules
@@ -271,9 +275,13 @@ makeClassy = makeLensesWith classyRules
--
-- will create
--
--- @'list' :: 'Iso' [a] [b] ('List' a) ('List' b)@
+-- @
+-- 'list' :: 'Iso' [a] [b] ('List' a) ('List' b)
+-- @
--
--- @'makeIso' = 'makeLensesWith' 'isoRules'@
+-- @
+-- 'makeIso' = 'makeLensesWith' 'isoRules'
+-- @
makeIso :: Name -> Q [Dec]
makeIso = makeLensesWith isoRules
@@ -297,7 +305,9 @@ makeLensesFor fields = makeLensesWith $ lensRules & lensField .~ (`Prelude.looku
--
-- Example usage:
--
--- @'makeClassyFor' \"HasFoo\" \"foo\" [(\"_foo\", \"fooLens\"), (\"bar\", \"lbar\")] ''Foo@
+-- @
+-- 'makeClassyFor' \"HasFoo\" \"foo\" [(\"_foo\", \"fooLens\"), (\"bar\", \"lbar\")] ''Foo
+-- @
makeClassyFor :: String -> String -> [(String, String)] -> Name -> Q [Dec]
makeClassyFor clsName funName fields = makeLensesWith $ classyRules
& lensClass .~ const (Just (clsName,funName))
90 src/Control/Lens/Traversal.hs
View
@@ -27,11 +27,15 @@
-- 'Traversable'. It allows you to 'traverse' over a structure and change out
-- its contents with monadic or 'Applicative' side-effects. Starting from
--
--- @'traverse' :: ('Traversable' t, 'Applicative' f) => (a -> f b) -> t a -> f (t b)@
+-- @
+-- 'traverse' :: ('Traversable' t, 'Applicative' f) => (a -> f b) -> t a -> f (t b)
+-- @
--
-- we monomorphize the contents and result to obtain
--
--- @type 'Traversal' s t a b = forall f. 'Applicative' f => (a -> f b) -> s -> f t@
+-- @
+-- type 'Traversal' s t a b = forall f. 'Applicative' f => (a -> f b) -> s -> f t
+-- @
--
-- While a 'Traversal' isn't quite a 'Fold', it _can_ be used for
-- 'Control.Lens.Getter.Getting' like a 'Fold', because given a
@@ -142,13 +146,17 @@ import Prelude hiding ((.),id)
-- | When you see this as an argument to a function, it expects a 'Traversal'.
type ATraversal s t a b = LensLike (Bazaar (->) a b) s t a b
--- | @type 'ATraversal'' = 'Simple' 'ATraversal'@
+-- | @
+-- type 'ATraversal'' = 'Simple' 'ATraversal'
+-- @
type ATraversal' s a = ATraversal s s a a
-- | When you see this as an argument to a function, it expects an 'IndexedTraversal'.
type AnIndexedTraversal i s t a b = Over (Indexed i) (Bazaar (Indexed i) a b) s t a b
--- | @type 'AnIndexedTraversal'' = 'Simple' ('AnIndexedTraversal' i)@
+-- | @
+-- type 'AnIndexedTraversal'' = 'Simple' ('AnIndexedTraversal' i)
+-- @
type AnIndexedTraversal' i s a = AnIndexedTraversal i s s a a
-- | When you see this as an argument to a function, it expects
@@ -166,7 +174,9 @@ type AnIndexedTraversal' i s a = AnIndexedTraversal i s s a a
-- * a 'Fold' if 'f' is 'Gettable' and 'Applicative'.
type Traversing p f s t a b = Over p (BazaarT p f a b) s t a b
--- | @type 'Traversing'' f = 'Simple' ('Traversing' f)@
+-- | @
+-- type 'Traversing'' f = 'Simple' ('Traversing' f)
+-- @
type Traversing' p f s a = Traversing p f s s a a
--------------------------
@@ -186,7 +196,9 @@ type Traversing' p f s a = Traversing p f s s a a
--
-- This yields the obvious law:
--
--- @'traverse' ≡ 'traverseOf' 'traverse'@
+-- @
+-- 'traverse' ≡ 'traverseOf' 'traverse'
+-- @
--
-- @
-- 'traverseOf' :: 'Iso' s t a b -> (a -> f b) -> s -> f t
@@ -199,7 +211,9 @@ traverseOf = id
-- | A version of 'traverseOf' with the arguments flipped, such that:
--
--- @'forOf' l ≡ 'flip' ('traverseOf' l)@
+-- @
+-- 'forOf' l ≡ 'flip' ('traverseOf' l)
+-- @
--
-- @
-- 'for' ≡ 'forOf' 'traverse'
@@ -208,7 +222,9 @@ traverseOf = id
--
-- This function is only provided for consistency, 'flip' is strictly more general.
--
--- @'forOf' ≡ 'flip'@
+-- @
+-- 'forOf' ≡ 'flip'
+-- @
--
-- @
-- 'forOf' :: 'Iso' s t a b -> s -> (a -> f b) -> f t
@@ -241,7 +257,7 @@ sequenceAOf l = l id
--
-- @
-- 'mapM' ≡ 'mapMOf' 'traverse'
--- 'imapMOf' l ≡ 'forM' l . 'Indexed'
+-- 'imapMOf' l ≡ 'forM' l '.' 'Indexed'
-- @
--
-- @
@@ -291,7 +307,9 @@ sequenceOf l = unwrapMonad #. l WrapMonad
--
-- Note: 'Data.List.transpose' handles ragged inputs more intelligently, but for non-ragged inputs:
--
--- @'Data.List.transpose' ≡ 'transposeOf' 'traverse'@
+-- @
+-- 'Data.List.transpose' ≡ 'transposeOf' 'traverse'
+-- @
--
-- >>> transposeOf traverse [[1,2,3],[4,5,6]]
-- [[1,4],[2,5],[3,6]]
@@ -299,14 +317,18 @@ sequenceOf l = unwrapMonad #. l WrapMonad
-- Since every 'Lens' is a 'Traversal', we can use this as a form of
-- monadic strength as well:
--
--- @'transposeOf' 'Control.Lens.Tuple._2' :: (b, [a]) -> [(b, a)]@
+-- @
+-- 'transposeOf' 'Control.Lens.Tuple._2' :: (b, [a]) -> [(b, a)]
+-- @
transposeOf :: LensLike ZipList s t [a] a -> s -> [t]
transposeOf l = getZipList #. l ZipList
{-# INLINE transposeOf #-}
-- | This generalizes 'Data.Traversable.mapAccumR' to an arbitrary 'Traversal'.
--
--- @'mapAccumR' ≡ 'mapAccumROf' 'traverse'@
+-- @
+-- 'mapAccumR' ≡ 'mapAccumROf' 'traverse'
+-- @
--
-- 'mapAccumROf' accumulates 'State' from right to left.
--
@@ -316,14 +338,18 @@ transposeOf l = getZipList #. l ZipList
-- 'mapAccumROf' :: 'Traversal' s t a b -> (acc -> a -> (acc, b)) -> acc -> s -> (acc, t)
-- @
--
--- @'mapAccumROf' :: 'LensLike' ('Backwards' ('State' acc)) s t a b -> (acc -> a -> (acc, b)) -> acc -> s -> (acc, t)@
+-- @
+-- 'mapAccumROf' :: 'LensLike' ('Backwards' ('State' acc)) s t a b -> (acc -> a -> (acc, b)) -> acc -> s -> (acc, t)
+-- @
mapAccumROf :: Conjoined p => Over p (Backwards (State acc)) s t a b -> p acc (a -> (acc, b)) -> acc -> s -> (acc, t)
mapAccumROf = mapAccumLOf . backwards
{-# INLINE mapAccumROf #-}
-- | This generalizes 'Data.Traversable.mapAccumL' to an arbitrary 'Traversal'.
--
--- @'mapAccumL' ≡ 'mapAccumLOf' 'traverse'@
+-- @
+-- 'mapAccumL' ≡ 'mapAccumLOf' 'traverse'
+-- @
--
-- 'mapAccumLOf' accumulates 'State' from left to right.
--
@@ -346,7 +372,9 @@ mapAccumLOf l f acc0 s = swap (runState (l g s) acc0) where
-- | This permits the use of 'scanr1' over an arbitrary 'Traversal' or 'Lens'.
--
--- @'scanr1' ≡ 'scanr1Of' 'traverse'@
+-- @
+-- 'scanr1' ≡ 'scanr1Of' 'traverse'
+-- @
--
-- @
-- 'scanr1Of' :: 'Iso' s t a a -> (a -> a -> a) -> s -> t
@@ -361,7 +389,9 @@ scanr1Of l f = snd . mapAccumROf l step Nothing where
-- | This permits the use of 'scanl1' over an arbitrary 'Traversal' or 'Lens'.
--
--- @'scanl1' ≡ 'scanl1Of' 'traverse'@
+-- @
+-- 'scanl1' ≡ 'scanl1Of' 'traverse'
+-- @
--
-- @
-- 'scanl1Of' :: 'Iso' s t a a -> (a -> a -> a) -> s -> t
@@ -708,7 +738,9 @@ dropping n l pafb s = snd $ runIndexing (l paifb s) 0 where
-- >>> foo both ("hello","world")
-- ("helloworld",(10,10))
--
--- @'cloneTraversal' :: 'LensLike' ('Bazaar' a b) s t a b -> 'Traversal' s t a b@
+-- @
+-- 'cloneTraversal' :: 'LensLike' ('Bazaar' a b) s t a b -> 'Traversal' s t a b
+-- @
cloneTraversal :: ATraversal s t a b -> Traversal s t a b
cloneTraversal l f s = runBazaar (l sell s) f
{-# INLINE cloneTraversal #-}
@@ -797,7 +829,9 @@ iforMOf = flip . imapMOf
--
-- 'imapAccumROf' accumulates state from right to left.
--
--- @'Control.Lens.Traversal.mapAccumROf' l ≡ 'imapAccumROf' l '.' 'const'@
+-- @
+-- 'Control.Lens.Traversal.mapAccumROf' l ≡ 'imapAccumROf' l '.' 'const'
+-- @
--
-- @
-- 'imapAccumROf' :: 'IndexedLens' i s t a b -> (i -> acc -> a -> (acc, b)) -> acc -> s -> (acc, t)
@@ -811,7 +845,9 @@ imapAccumROf l = mapAccumROf l .# Indexed
--
-- 'imapAccumLOf' accumulates state from left to right.
--
--- @'Control.Lens.Traversal.mapAccumLOf' l ≡ 'imapAccumLOf' l '.' 'const'@
+-- @
+-- 'Control.Lens.Traversal.mapAccumLOf' l ≡ 'imapAccumLOf' l '.' 'const'
+-- @
--
-- @
-- 'imapAccumLOf' :: 'IndexedLens' i s t a b -> (i -> acc -> a -> (acc, b)) -> acc -> s -> (acc, t)
@@ -837,9 +873,13 @@ traversed64 = indexing64 traverse
-- | This is the trivial empty 'Traversal'.
--
--- @'ignored' :: 'IndexedTraversal' i s s a b@
+-- @
+-- 'ignored' :: 'IndexedTraversal' i s s a b
+-- @
--
--- @'ignored' ≡ 'const' 'pure'@
+-- @
+-- 'ignored' ≡ 'const' 'pure'
+-- @
ignored :: Applicative f => pafb -> s -> f s
ignored _ = pure
{-# INLINE ignored #-}
@@ -914,7 +954,9 @@ elementOf l p = elementsOf l (p ==)
-- | Traverse the /nth/ element of a 'Traversable' container.
--
--- @'element' ≡ 'elementOf' 'traverse'@
+-- @
+-- 'element' ≡ 'elementOf' 'traverse'
+-- @
element :: Traversable t => Int -> IndexedTraversal' Int (t a) a
element = elementOf traverse
{-# INLINE element #-}
@@ -934,7 +976,9 @@ elementsOf l p iafb s = snd $ runIndexing (l (\a -> Indexing (\i -> i `seq` (i +
-- | Traverse elements of a 'Traversable' container where their ordinal positions matches a predicate.
--
--- @'elements' ≡ 'elementsOf' 'traverse'@
+-- @
+-- 'elements' ≡ 'elementsOf' 'traverse'
+-- @
elements :: Traversable t => (Int -> Bool) -> IndexedTraversal' Int (t a) a
elements = elementsOf traverse
{-# INLINE elements #-}
8 src/Control/Lens/Tuple.hs
View
@@ -76,7 +76,9 @@ class Field1 s t a b | s -> a, t -> b, s b -> t, t a -> s where
instance Field1 (Identity a) (Identity b) a b where
_1 f (Identity a) = Identity <$> indexed f (0 :: Int) a
--- | @'_1' k ~(a,b) = (\\a' -> (a',b)) 'Data.Functor.<$>' k a@
+-- | @
+-- '_1' k ~(a,b) = (\\a' -> (a',b)) 'Data.Functor.<$>' k a
+-- @
instance Field1 (a,b) (a',b) a a' where
_1 k ~(a,b) = indexed k (0 :: Int) a <&> \a' -> (a',b)
{-# INLINE _1 #-}
@@ -130,7 +132,9 @@ class Field2 s t a b | s -> a, t -> b, s b -> t, t a -> s where
-- @
_2 :: IndexedLens Int s t a b
--- | @'_2' k ~(a,b) = (\\b' -> (a,b')) 'Data.Functor.<$>' k b@
+-- | @
+-- '_2' k ~(a,b) = (\\b' -> (a,b')) 'Data.Functor.<$>' k b
+-- @
instance Field2 (a,b) (a,b') b b' where
_2 k ~(a,b) = indexed k (1 :: Int) b <&> \b' -> (a,b')
{-# INLINE _2 #-}
92 src/Control/Lens/Type.hs
View
@@ -83,15 +83,21 @@ import Data.Profunctor
--
-- 1) You get back what you put in:
--
--- @'Control.Lens.Getter.view' l ('Control.Lens.Setter.set' l b a) ≡ b@
+-- @
+-- 'Control.Lens.Getter.view' l ('Control.Lens.Setter.set' l b a) ≡ b
+-- @
--
-- 2) Putting back what you got doesn't change anything:
--
--- @'Control.Lens.Setter.set' l ('Control.Lens.Getter.view' l a) a ≡ a@
+-- @
+-- 'Control.Lens.Setter.set' l ('Control.Lens.Getter.view' l a) a ≡ a
+-- @
--
-- 3) Setting twice is the same as setting once:
--
--- @'Control.Lens.Setter.set' l c ('Control.Lens.Setter.set' l b a) ≡ 'Control.Lens.Setter.set' l c a@
+-- @
+-- 'Control.Lens.Setter.set' l c ('Control.Lens.Setter.set' l b a) ≡ 'Control.Lens.Setter.set' l c a
+-- @
--
-- These laws are strong enough that the 4 type parameters of a 'Lens' cannot
-- vary fully independently. For more on how they interact, read the \"Why is
@@ -112,22 +118,30 @@ import Data.Profunctor
-- 'fmap' (l f) '.' l g ≡ 'Data.Functor.Compose.getCompose' '.' l ('Data.Functor.Compose.Compose' '.' 'fmap' f '.' g)
-- @
--
--- @type 'Lens' s t a b = forall f. 'Functor' f => 'LensLike' f s t a b@
+-- @
+-- type 'Lens' s t a b = forall f. 'Functor' f => 'LensLike' f s t a b
+-- @
type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t
--- | @type 'Lens'' = 'Simple' 'Lens'@
+-- | @
+-- type 'Lens'' = 'Simple' 'Lens'
+-- @
type Lens' s a = Lens s s a a
-- | Every 'IndexedLens' is a valid 'Lens' and a valid 'Control.Lens.Traversal.IndexedTraversal'.
type IndexedLens i s t a b = forall f p. (Indexable i p, Functor f) => p a (f b) -> s -> f t
--- | @type 'IndexedLens'' i = 'Simple' ('IndexedLens' i)@
+-- | @
+-- type 'IndexedLens'' i = 'Simple' ('IndexedLens' i)
+-- @
type IndexedLens' i s a = IndexedLens i s s a a
-- | An 'IndexPreservingLens' leaves any index it is composed with alone.
type IndexPreservingLens s t a b = forall p f. (Conjoined p, Functor f) => p a (f b) -> p s (f t)
--- | @type 'IndexPreservingLens'' = 'Simple' 'IndexPreservingLens'@
+-- | @
+-- type 'IndexPreservingLens'' = 'Simple' 'IndexPreservingLens'
+-- @
type IndexPreservingLens' s a = IndexPreservingLens s s a a
------------------------------------------------------------------------------
@@ -139,7 +153,9 @@ type IndexPreservingLens' s a = IndexPreservingLens s s a a
--
-- These have also been known as multilenses, but they have the signature and spirit of
--
--- @'Data.Traversable.traverse' :: 'Data.Traversable.Traversable' f => 'Traversal' (f a) (f b) a b@
+-- @
+-- 'Data.Traversable.traverse' :: 'Data.Traversable.Traversable' f => 'Traversal' (f a) (f b) a b
+-- @
--
-- and the more evocative name suggests their application.
--
@@ -161,7 +177,9 @@ type IndexPreservingLens' s a = IndexPreservingLens s s a a
-- second law in that same paper!
type Traversal s t a b = forall f. Applicative f => (a -> f b) -> s -> f t
--- | @type 'Traversal'' = 'Simple' 'Traversal'@
+-- | @
+-- type 'Traversal'' = 'Simple' 'Traversal'
+-- @
type Traversal' s a = Traversal s s a a
-- | Every 'IndexedTraversal' is a valid 'Control.Lens.Traversal.Traversal' or
@@ -173,13 +191,17 @@ type Traversal' s a = Traversal s s a a
-- The 'Control.Lens.Traversal.Traversal' laws are still required to hold.
type IndexedTraversal i s t a b = forall p f. (Indexable i p, Applicative f) => p a (f b) -> s -> f t
--- | @type 'IndexedTraversal'' i = 'Simple' ('IndexedTraversal' i)@
+-- | @
+-- type 'IndexedTraversal'' i = 'Simple' ('IndexedTraversal' i)
+-- @
type IndexedTraversal' i s a = IndexedTraversal i s s a a
-- | An 'IndexPreservingLens' leaves any index it is composed with alone.
type IndexPreservingTraversal s t a b = forall p f. (Conjoined p, Applicative f) => p a (f b) -> p s (f t)
--- | @type 'IndexPreservingTraversal'' = 'Simple' 'IndexPreservingTraversal'@
+-- | @
+-- type 'IndexPreservingTraversal'' = 'Simple' 'IndexPreservingTraversal'
+-- @
type IndexPreservingTraversal' s a = IndexPreservingTraversal s s a a
------------------------------------------------------------------------------
@@ -188,7 +210,9 @@ type IndexPreservingTraversal' s a = IndexPreservingTraversal s s a a
-- | The only 'LensLike' law that can apply to a 'Setter' @l@ is that
--
--- @'Control.Lens.Setter.set' l y ('Control.Lens.Setter.set' l x a) ≡ 'Control.Lens.Setter.set' l y a@
+-- @
+-- 'Control.Lens.Setter.set' l y ('Control.Lens.Setter.set' l x a) ≡ 'Control.Lens.Setter.set' l y a
+-- @
--
-- You can't 'Control.Lens.Getter.view' a 'Setter' in general, so the other two laws are irrelevant.
--
@@ -229,9 +253,13 @@ type Setter s t a b = forall f. Settable f => (a -> f b) -> s -> f t
--
-- These are particularly common when talking about monomorphic containers. /e.g./
--
--- @'sets' Data.Text.map :: 'Setter'' 'Data.Text.Internal.Text' 'Char'@
+-- @
+-- 'sets' Data.Text.map :: 'Setter'' 'Data.Text.Internal.Text' 'Char'
+-- @
--
--- @type 'Setter'' = 'Setter''@
+-- @
+-- type 'Setter'' = 'Setter''
+-- @
type Setter' s a = Setter s s a a
-- | Every 'IndexedSetter' is a valid 'Setter'.
@@ -240,7 +268,9 @@ type Setter' s a = Setter s s a a
type IndexedSetter i s t a b = forall f p.
(Indexable i p, Settable f) => p a (f b) -> s -> f t
--- | @type 'IndexedSetter'' i = 'Simple' ('IndexedSetter' i)@
+-- | @
+-- type 'IndexedSetter'' i = 'Simple' ('IndexedSetter' i)
+-- @
type IndexedSetter' i s a = IndexedSetter i s s a a
-- | An 'IndexPreservingSetter' can be composed with a 'IndexedSetter', 'IndexedTraversal' or 'IndexedLens'
@@ -258,7 +288,9 @@ type IndexPreservingSetter' s a = IndexPreservingSetter s s a a
-- Note: Composition with an 'Iso' is index- and measure- preserving.
type Iso s t a b = forall p f. (Profunctor p, Functor f) => p a (f b) -> p s (f t)
--- | @type 'Iso'' = 'Control.Lens.Type.Simple' 'Iso'@
+-- | @
+-- type 'Iso'' = 'Control.Lens.Type.Simple' 'Iso'
+-- @
type Iso' s a = Iso s s a a
------------------------------------------------------------------------------
@@ -273,7 +305,9 @@ type Iso' s a = Iso s s a a
--
-- First, if I 'Control.Lens.Review.re' or 'Control.Lens.Prism.review' a value with a 'Prism' and then 'Control.Lens.Prism.preview' or use ('Control.Lens.Fold.^?'), I will get it back:
--
--- @'Control.Lens.Prism.preview' l ('Control.Lens.Prism.review' l b) ≡ 'Just' b@
+-- @
+-- 'Control.Lens.Prism.preview' l ('Control.Lens.Prism.review' l b) ≡ 'Just' b
+-- @
--
-- Second, if you can extract a value @a@ using a 'Prism' @l@ from a value @s@, then the value @s@ is completely described my @l@ and @a@:
--
@@ -281,7 +315,9 @@ type Iso' s a = Iso s s a a
--
-- These two laws imply that the 'Traversal' laws hold for every 'Prism' and that we 'Data.Traversable.traverse' at most 1 element:
--
--- @'Control.Lens.Fold.lengthOf' l x '<=' 1@
+-- @
+-- 'Control.Lens.Fold.lengthOf' l x '<=' 1
+-- @
--
-- It may help to think of this as a 'Iso' that can be partial in one direction.
--
@@ -467,16 +503,24 @@ type IndexPreservingMonadicFold m s a = forall p f r. (Conjoined p, Effective m
-- This is commonly abbreviated as a \"prime\" marker, /e.g./ 'Lens'' = 'Simple' 'Lens'.
type Simple f s a = f s s a a
--- | @type 'LensLike' f s t a b = 'Overloading' (->) (->) f s t a b@
+-- | @
+-- type 'LensLike' f s t a b = 'Overloading' (->) (->) f s t a b
+-- @
type Overloading p q f s t a b = p a (f b) -> q s (f t)
--- | @type 'Overloading'' p q f s a = 'Simple' ('Overloading' p q f) s a@
+-- | @
+-- type 'Overloading'' p q f s a = 'Simple' ('Overloading' p q f) s a
+-- @
type Overloading' p q f s a = Overloading p q f s s a a
--- | @type 'LensLike' f s t a b = 'Overloaded' (->) f s t a b@
+-- | @
+-- type 'LensLike' f s t a b = 'Overloaded' (->) f s t a b
+-- @
type Overloaded p f s t a b = p a (f b) -> p s (f t)
--- | @type 'Overloaded'' p q f s a = 'Simple' ('Overloaded' p q f) s a@
+-- | @
+-- type 'Overloaded'' p q f s a = 'Simple' ('Overloaded' p q f) s a
+-- @
type Overloaded' p f s a = Overloaded p f s s a a
-- | Many combinators that accept a 'Lens' can also accept a
@@ -492,7 +536,9 @@ type Overloaded' p f s a = Overloaded p f s s a a
-- 'Traversal'.
type LensLike f s t a b = (a -> f b) -> s -> f t
--- | @type 'LensLike'' f = 'Simple' ('LensLike' f)@
+-- | @
+-- type 'LensLike'' f = 'Simple' ('LensLike' f)
+-- @
type LensLike' f s a = LensLike f s s a a
-- | Convenient alias for constructing indexed lenses and their ilk.
4 src/Control/Lens/Zoom.hs
View
@@ -182,7 +182,9 @@ instance Monad m => Magnify (ReaderT b m) (ReaderT a m) b a where
magnify l (ReaderT m) = ReaderT $ getEffect #. l (Effect #. m)
{-# INLINE magnify #-}
--- | @'magnify' = 'views'@
+-- | @
+-- 'magnify' = 'views'
+-- @
instance Magnify ((->) b) ((->) a) b a where
magnify = views
{-# INLINE magnify #-}
Please sign in to comment.
Something went wrong with that request. Please try again.