Permalink
Browse files

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

… to form @\ncode\n@, ACT II
  • Loading branch information...
1 parent d5c0462 commit f502561ad1dda7dde0b468d7ec4d75bcafddb932 @basdirks basdirks committed Jan 21, 2013
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 #-}
@@ -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,23 +242,29 @@ 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
-- | Left-associative fold of an indexed container with access to the index @i@.
--
-- 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
-- | /Strictly/ fold right over the elements of a structure with access to the index @i@.
--
-- 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,19 +345,25 @@ 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_ #-}
-- | 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 #-}
@@ -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
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 #-}
Oops, something went wrong.

0 comments on commit f502561

Please sign in to comment.