Permalink
Browse files

Shorter signatures

  • Loading branch information...
1 parent deb6b7f commit 7440d39c6db450c10d7e4e286736916f37309001 @ekmett committed Jan 16, 2013
Showing with 29 additions and 29 deletions.
  1. +1 −1 src/Control/Lens/Fold.hs
  2. +3 −3 src/Control/Lens/Lens.hs
  3. +22 −22 src/Control/Lens/Traversal.hs
  4. +3 −3 src/Control/Lens/Type.hs
View
@@ -395,7 +395,7 @@ droppingWhile p l f = (flip evalState True .# getCompose) `rmap` l g where
-- @
--
-- @'foldMapOf' :: 'Getting' r s t a b -> (a -> r) -> s -> r@
-foldMapOf :: Profunctor p => Overloading p (->) (Accessor r) s t a b -> p a r -> s -> r
+foldMapOf :: Profunctor p => Accessing p r s t a b -> p a r -> s -> r
foldMapOf l f = runAccessor #. l (Accessor #. f)
{-# INLINE foldMapOf #-}
View
@@ -777,7 +777,7 @@ l <%@~ f = l (Indexed $ \i a -> let b = f i a in (b, b))
-- ('%%@~') :: 'IndexedLens' i s t a b -> (i -> a -> (r, b)) -> s -> (r, t)
-- ('%%@~') :: 'Monoid' r => 'Control.Lens.Traversal.IndexedTraversal' i s t a b -> (i -> a -> (r, b)) -> s -> (r, t)
-- @
-(%%@~) :: Lensing (Indexed i) f s t a b -> (i -> a -> f b) -> s -> f t
+(%%@~) :: IndexedLensLike i f s t a b -> (i -> a -> f b) -> s -> f t
(%%@~) l = l .# Indexed
{-# INLINE (%%@~) #-}
@@ -791,7 +791,7 @@ l <%@~ f = l (Indexed $ \i a -> let b = f i a in (b, b))
-- ('%%@=') :: 'MonadState' s m 'IndexedLens' i s s a b -> (i -> a -> (r, b)) -> s -> m r
-- ('%%@=') :: ('MonadState' s m, 'Monoid' r) => 'Control.Lens.Traversal.IndexedTraversal' i s s a b -> (i -> a -> (r, b)) -> s -> m r
-- @
-(%%@=) :: MonadState s m => Lensing (Indexed i) ((,) r) s s a b -> (i -> a -> (r, b)) -> m r
+(%%@=) :: MonadState s m => IndexedLensLike i ((,) r) s s a b -> (i -> a -> (r, b)) -> m r
#if MIN_VERSION_mtl(2,1,0)
l %%@= f = State.state (l %%@~ f)
#else
@@ -810,7 +810,7 @@ l %%@= f = do
-- ('<%@=') :: 'MonadState' s m 'IndexedLens' i s s a b -> (i -> a -> b) -> m b
-- ('<%@=') :: ('MonadState' s m, 'Monoid' b) => 'Control.Lens.Traversal.IndexedTraversal' i s s a b -> (i -> a -> b) -> m b
-- @
-(<%@=) :: MonadState s m => Lensing (Indexed i) ((,) b) s s a b -> (i -> a -> b) -> m b
+(<%@=) :: MonadState s m => IndexedLensLike i ((,) b) s s a b -> (i -> a -> b) -> m b
l <%@= f = l %%@= \ i a -> let b = f i a in (b, b)
{-# INLINE (<%@=) #-}
@@ -145,7 +145,7 @@ type ATraversal s t a b = LensLike (Bazaar (->) a b) s t a b
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 = Lensing (Indexed i) (Bazaar (Indexed i) a b) s t a b
+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' i s a = AnIndexedTraversal i s s a a
@@ -163,7 +163,7 @@ type AnIndexedTraversal' i s a = AnIndexedTraversal i s s a a
-- * a 'Lens' if @p@ is only a 'Functor',
--
-- * a 'Fold' if 'f' is 'Gettable' and 'Applicative'.
-type Traversing p f s t a b = Overloading p (->) (BazaarT p f a b) s t a b
+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' p f s a = Traversing p f s s a a
@@ -192,7 +192,7 @@ type Traversing' p f s a = Traversing p f s s a a
-- 'traverseOf' :: 'Lens' s t a b -> (a -> f b) -> s -> f t
-- 'traverseOf' :: 'Traversal' s t a b -> (a -> f b) -> s -> f t
-- @
-traverseOf :: Overloading p (->) f s t a b -> p a (f b) -> s -> f t
+traverseOf :: Over p f s t a b -> p a (f b) -> s -> f t
traverseOf = id
{-# INLINE traverseOf #-}
@@ -214,7 +214,7 @@ traverseOf = id
-- 'forOf' :: 'Lens' s t a b -> s -> (a -> f b) -> f t
-- 'forOf' :: 'Traversal' s t a b -> s -> (a -> f b) -> f t
-- @
-forOf :: Overloading p (->) f s t a b -> s -> p a (f b) -> f t
+forOf :: Over p f s t a b -> s -> p a (f b) -> f t
forOf = flip
{-# INLINE forOf #-}
@@ -248,7 +248,7 @@ sequenceAOf l = l id
-- 'mapMOf' :: 'Lens' s t a b -> (a -> m b) -> s -> m t
-- 'mapMOf' :: 'Monad' m => 'Traversal' s t a b -> (a -> m b) -> s -> m t
-- @
-mapMOf :: Profunctor p => Overloading p (->) (WrappedMonad m) s t a b -> p a (m b) -> s -> m t
+mapMOf :: Profunctor p => Over p (WrappedMonad m) s t a b -> p a (m b) -> s -> m t
mapMOf l cmd = unwrapMonad #. l (WrapMonad #. cmd)
{-# INLINE mapMOf #-}
@@ -265,7 +265,7 @@ mapMOf l cmd = unwrapMonad #. l (WrapMonad #. cmd)
-- 'forMOf' :: 'Lens' s t a b -> s -> (a -> m b) -> m t
-- 'forMOf' :: 'Monad' m => 'Traversal' s t a b -> s -> (a -> m b) -> m t
-- @
-forMOf :: Profunctor p => Overloading p (->) (WrappedMonad m) s t a b -> s -> p a (m b) -> m t
+forMOf :: Profunctor p => Over p (WrappedMonad m) s t a b -> s -> p a (m b) -> m t
forMOf l a cmd = unwrapMonad (l (WrapMonad #. cmd) a)
{-# INLINE forMOf #-}
@@ -316,7 +316,7 @@ transposeOf l = getZipList #. l ZipList
-- @
--
-- @'mapAccumROf' :: 'LensLike' ('Backwards' ('State' acc)) s t a b -> (acc -> a -> (acc, b)) -> acc -> s -> (acc, t)@
-mapAccumROf :: (Corepresentable p, Comonad (Corep p)) => Overloading p (->) (Backwards (State acc)) s t a b -> p acc (a -> (acc, b)) -> acc -> s -> (acc, t)
+mapAccumROf :: (Corepresentable p, Comonad (Corep p)) => Over p (Backwards (State acc)) s t a b -> p acc (a -> (acc, b)) -> acc -> s -> (acc, t)
mapAccumROf = mapAccumLOf . backwards
{-# INLINE mapAccumROf #-}
@@ -337,7 +337,7 @@ mapAccumROf = mapAccumLOf . backwards
-- 'mapAccumLOf' l f acc0 s = 'swap' ('runState' (l (\a -> 'state' (\acc -> 'swap' (f acc a))) s) acc0)
-- @
--
-mapAccumLOf :: (Corepresentable p, Comonad (Corep p)) => Overloading p (->) (State acc) s t a b -> p acc (a -> (acc, b)) -> acc -> s -> (acc, t)
+mapAccumLOf :: (Corepresentable p, Comonad (Corep p)) => Over p (State acc) s t a b -> p acc (a -> (acc, b)) -> acc -> s -> (acc, t)
mapAccumLOf l f acc0 s = swap (runState (l g s) acc0) where
g = cotabulate $ \wa -> state $ \acc -> swap (corep f (acc <$ wa) (extract wa))
-- This would be much cleaner if the argument order for the function was swapped.
@@ -404,7 +404,7 @@ partsOf l f s = outs b <$> f (ins b) where b = l sell s
{-# INLINE partsOf #-}
-- | An indexed version of 'partsOf' that receives the entire list of indices as its index.
-ipartsOf :: forall i p f s t a. (Indexable [i] p, Functor f) => Traversing (Indexed i) f s t a a -> Overloading p (->) f s t [a] [a]
+ipartsOf :: forall i p f s t a. (Indexable [i] p, Functor f) => Traversing (Indexed i) f s t a a -> Over p f s t [a] [a]
ipartsOf l f s = outs b <$> indexed f (is :: [i]) as where
(is,as) = unzip (pins b)
b = l sell s
@@ -416,7 +416,7 @@ partsOf' l f s = outs b <$> f (ins b) where b = l sell s
{-# INLINE partsOf' #-}
-- | A type-restricted version of 'ipartsOf' that can only be used with an 'IndexedTraversal'.
-ipartsOf' :: forall i p f s t a. (Indexable [i] p, Functor f) => Overloading (Indexed i) (->) (Bazaar' (Indexed i) a) s t a a -> Overloading p (->) f s t [a] [a]
+ipartsOf' :: forall i p f s t a. (Indexable [i] p, Functor f) => Over (Indexed i) (Bazaar' (Indexed i) a) s t a a -> Over p f s t [a] [a]
ipartsOf' l f s = outs b <$> indexed f (is :: [i]) as where
(is,as) = unzip (pins b)
b = l sell s
@@ -447,7 +447,7 @@ unsafePartsOf l f s = unsafeOuts b <$> f (ins b) where b = l sell s
{-# INLINE unsafePartsOf #-}
-- | An indexed version of 'unsafePartsOf' that receives the entire list of indices as its index.
-iunsafePartsOf :: forall i p f s t a b. (Indexable [i] p, Functor f) => Traversing (Indexed i) f s t a b -> Overloading p (->) f s t [a] [b]
+iunsafePartsOf :: forall i p f s t a b. (Indexable [i] p, Functor f) => Traversing (Indexed i) f s t a b -> Over p f s t [a] [b]
iunsafePartsOf l f s = unsafeOuts b <$> indexed f (is :: [i]) as where
(is,as) = unzip (pins b)
b = l sell s
@@ -457,7 +457,7 @@ unsafePartsOf' :: ATraversal s t a b -> Lens s t [a] [b]
unsafePartsOf' l f s = unsafeOuts b <$> f (ins b) where b = l sell s
{-# INLINE unsafePartsOf' #-}
-iunsafePartsOf' :: forall i p s t a b. Indexable [i] p => Overloading (Indexed i) (->) (Bazaar (Indexed i) a b) s t a b -> IndexedLens [i] s t [a] [b]
+iunsafePartsOf' :: forall i p s t a b. Indexable [i] p => Over (Indexed i) (Bazaar (Indexed i) a b) s t a b -> IndexedLens [i] s t [a] [b]
iunsafePartsOf' l f s = unsafeOuts b <$> indexed f (is :: [i]) as where
(is,as) = unzip (pins b)
b = l sell s
@@ -479,7 +479,7 @@ iunsafePartsOf' l f s = unsafeOuts b <$> indexed f (is :: [i]) as where
-- 'holesOf' :: 'IndexedLens'' i s a -> s -> ['Pretext'' ('Indexed' i) a s]
-- 'holesOf' :: 'IndexedTraversal'' i s a -> s -> ['Pretext'' ('Indexed' i) a s]
-- @
-holesOf :: (Corepresentable p, Comonad (Corep p)) => Overloading p (->) (Bazaar p a a) s t a a -> s -> [Pretext p a a t]
+holesOf :: (Corepresentable p, Comonad (Corep p)) => Over p (Bazaar p a a) s t a a -> s -> [Pretext p a a t]
holesOf l s = f (pins b) (unsafeOuts b) where
b = l sell s
f [] _ = []
@@ -502,8 +502,8 @@ holesOf l s = f (pins b) (unsafeOuts b) where
-- 'singular' :: 'IndexedMonadicFold' i m s a -> 'IndexedAction' i m s a
-- @
singular :: (Corepresentable p, Comonad (Corep p), Functor f)
- => Overloading p (->) (BazaarT p f a a) s t a a
- -> Overloading p (->) f s t a a
+ => Over p (BazaarT p f a a) s t a a
+ -> Over p f s t a a
singular l pafb s = case pins b of
(w:ws) -> unsafeOuts b . (:Prelude.map extract ws) <$> corep pafb w
[] -> unsafeOuts b . return <$> corep pafb (error "singular: empty traversal")
@@ -525,8 +525,8 @@ singular l pafb s = case pins b of
-- 'unsafeSingular' :: 'IndexedMonadicFold' i m s a -> 'IndexedAction' i m s a
-- @
unsafeSingular :: (Corepresentable p, Comonad (Corep p), Functor f)
- => Overloading p (->) (BazaarT p f a b) s t a b
- -> Overloading p (->) f s t a b
+ => Over p (BazaarT p f a b) s t a b
+ -> Over p f s t a b
unsafeSingular l pafb s = case pins b of
[w] -> unsafeOuts b . return <$> corep pafb w
[] -> error "unsafeSingular: empty traversal"
@@ -649,8 +649,8 @@ beside l r f = tabulate $ \ ~(s,s') -> liftA2 (,) <$> rep (l f) s <*> rep (r f)
-- @
taking :: (Corepresentable p, Category p, Applicative f)
=> Int
- -> Overloading p (->) (BazaarT p f a a) s t a a
- -> Overloading p (->) f s t a a
+ -> Over p (BazaarT p f a a) s t a a
+ -> Over p f s t a a
taking n l pafb s = outs b <$> traverse (corep pafb) (take n $ pins b) where b = l sell s
{-# INLINE taking #-}
@@ -680,7 +680,7 @@ taking n l pafb s = outs b <$> traverse (corep pafb) (take n $ pins b) where b =
-- 'dropping' :: 'Int' -> 'IndexedAction' i m s a -> 'IndexedMonadicFold' i m s a
-- 'dropping' :: 'Int' -> 'IndexedMonadicFold' i m s a -> 'IndexedMonadicFold' i m s a
-- @
-dropping :: (Corepresentable p, Comonad (Corep p), Applicative f) => Int -> Overloading p (->) (Indexing f) s t a a -> Overloading p (->) f s t a a
+dropping :: (Corepresentable p, Comonad (Corep p), Applicative f) => Int -> Over p (Indexing f) s t a a -> Over p f s t a a
dropping n l pafb s = snd $ runIndexing (l paifb s) 0 where
paifb = cotabulate $ \wa -> Indexing $ \i -> let i' = i + 1 in i' `seq` (i', if i < n then pure (extract wa) else corep pafb wa)
{-# INLINE dropping #-}
@@ -802,7 +802,7 @@ iforMOf = flip . imapMOf
-- 'imapAccumROf' :: 'IndexedLens' i s t a b -> (i -> acc -> a -> (acc, b)) -> acc -> s -> (acc, t)
-- 'imapAccumROf' :: 'IndexedTraversal' i s t a b -> (i -> acc -> a -> (acc, b)) -> acc -> s -> (acc, t)
-- @
-imapAccumROf :: Overloading (Indexed i) (->) (Backwards (State acc)) s t a b -> (i -> acc -> a -> (acc, b)) -> acc -> s -> (acc, t)
+imapAccumROf :: Over (Indexed i) (Backwards (State acc)) s t a b -> (i -> acc -> a -> (acc, b)) -> acc -> s -> (acc, t)
imapAccumROf l = mapAccumROf l .# Indexed
{-# INLINE imapAccumROf #-}
@@ -816,7 +816,7 @@ imapAccumROf l = mapAccumROf l .# Indexed
-- 'imapAccumLOf' :: 'IndexedLens' i s t a b -> (i -> acc -> a -> (acc, b)) -> acc -> s -> (acc, t)
-- 'imapAccumLOf' :: 'IndexedTraversal' i s t a b -> (i -> acc -> a -> (acc, b)) -> acc -> s -> (acc, t)
-- @
-imapAccumLOf :: Overloading (Indexed i) (->) (State acc) s t a b -> (i -> acc -> a -> (acc, b)) -> acc -> s -> (acc, t)
+imapAccumLOf :: Over (Indexed i) (State acc) s t a b -> (i -> acc -> a -> (acc, b)) -> acc -> s -> (acc, t)
imapAccumLOf l = mapAccumLOf l .# Indexed
{-# INLINE imapAccumLOf #-}
View
@@ -46,7 +46,7 @@ module Control.Lens.Type
-- * Common
, Simple
, LensLike, LensLike'
- , Lensing, Lensing'
+ , Over, Over'
, IndexedLensLike, IndexedLensLike'
, Overloading, Overloading'
, Overloaded, Overloaded'
@@ -501,6 +501,6 @@ type IndexedLensLike i f s t a b = forall p. Indexable i p => p a (f b) -> s ->
-- | Convenient alias for constructing simple indexed lenses and their ilk.
type IndexedLensLike' i f s a = IndexedLensLike i f s s a a
-type Lensing p f s t a b = p a (f b) -> s -> f t
+type Over p f s t a b = p a (f b) -> s -> f t
-type Lensing' p f s a = Lensing p f s s a a
+type Over' p f s a = Over p f s s a a

0 comments on commit 7440d39

Please sign in to comment.