lens-3.7.0.2: Lenses, Folds and Traversals

PortabilityRank2Types
Stabilityprovisional
MaintainerEdward Kmett <ekmett@gmail.com>
Safe HaskellTrustworthy

Control.Lens.Internal

Contents

Description

These are some of the explicit Functor instances that leak into the type signatures of Control.Lens. You shouldn't need to import this module directly, unless you are coming up with a whole new kind of "Family" and need to add instances.

Synopsis

Internal Types

newtype May a Source

Make a monoid out of Maybe for error handling

Constructors

May 

Fields

getMay :: Maybe a
 

Instances

Monoid a => Monoid (May a) 

newtype Folding f a Source

Constructors

Folding 

Fields

getFolding :: f a
 

Instances

newtype Effect m r a Source

Wrap a monadic effect with a phantom type argument.

Constructors

Effect 

Fields

getEffect :: m r
 

Instances

(Gettable (Effect m r), Monad m) => Effective m r (Effect m r) 
Functor (Effect m r) 
(Functor (Effect m r), Monad m, Monoid r) => Applicative (Effect m r) 
Functor (Effect m r) => Gettable (Effect m r) 
(MonadReader b (ReaderT b m), MonadReader a (ReaderT a m), Monad m) => Magnify (ReaderT b m) (ReaderT a m) (Effect m) b a 
(Monad m, Monoid r) => Monoid (Effect m r a) 

newtype EffectRWS w st m s a Source

Wrap a monadic effect with a phantom type argument. Used when magnifying RWST.

Constructors

EffectRWS 

Fields

getEffectRWS :: st -> m (s, st, w)
 

Instances

Functor (EffectRWS w st m s) 
(Functor (EffectRWS w st m s), Monoid s, Monoid w, Monad m) => Applicative (EffectRWS w st m s) 
Functor (EffectRWS w st m s) => Gettable (EffectRWS w st m s) 
(MonadReader b (RWST b w s m), MonadReader a (RWST a w s m), Monad m, Monoid w) => Magnify (RWST b w s m) (RWST a w s m) (EffectRWS w s m) b a 
(MonadReader b (RWST b w s m), MonadReader a (RWST a w s m), Monad m, Monoid w) => Magnify (RWST b w s m) (RWST a w s m) (EffectRWS w s m) b a 

newtype Accessor r a Source

Used instead of Const to report

No instance of (Settable Accessor)

when the user attempts to misuse a Setter as a Getter, rather than a monolithic unification error.

Constructors

Accessor 

Fields

runAccessor :: r
 

Instances

newtype Err e a Source

Make a monoid out of Either for error handling

Constructors

Err 

Fields

getErr :: Either e a
 

Instances

Monoid a => Monoid (Err e a) 

newtype Traversed f Source

Used internally by traverseOf_ and the like.

Constructors

Traversed 

Fields

getTraversed :: f ()
 

Instances

newtype Sequenced m Source

Used internally by mapM_ and the like.

Constructors

Sequenced 

Fields

getSequenced :: m ()
 

Instances

newtype Focusing m s a Source

Used by Zoom to zoom into StateT

Constructors

Focusing 

Fields

unfocusing :: m (s, a)
 

Instances

Monad m => Functor (Focusing m s) 
(Functor (Focusing m s), Monad m, Monoid s) => Applicative (Focusing m s) 
(MonadState s (StateT s z), MonadState t (StateT t z), Monad z) => Zoom (StateT s z) (StateT t z) (Focusing z) s t 
(MonadState s (StateT s z), MonadState t (StateT t z), Monad z) => Zoom (StateT s z) (StateT t z) (Focusing z) s t 

newtype FocusingWith w m s a Source

Used by Zoom to zoom into RWST

Constructors

FocusingWith 

Fields

unfocusingWith :: m (s, a, w)
 

Instances

Monad m => Functor (FocusingWith w m s) 
(Functor (FocusingWith w m s), Monad m, Monoid s, Monoid w) => Applicative (FocusingWith w m s) 
(MonadState s (RWST r w s z), MonadState t (RWST r w t z), Monoid w, Monad z) => Zoom (RWST r w s z) (RWST r w t z) (FocusingWith w z) s t 
(MonadState s (RWST r w s z), MonadState t (RWST r w t z), Monoid w, Monad z) => Zoom (RWST r w s z) (RWST r w t z) (FocusingWith w z) s t 

newtype FocusingPlus w k s a Source

Used by Zoom to zoom into WriterT.

Constructors

FocusingPlus 

Fields

unfocusingPlus :: k (s, w) a
 

Instances

(MonadState s (WriterT w m), MonadState t (WriterT w n), Monoid w, Zoom m n k s t) => Zoom (WriterT w m) (WriterT w n) (FocusingPlus w k) s t 
(MonadState s (WriterT w m), MonadState t (WriterT w n), Monoid w, Zoom m n k s t) => Zoom (WriterT w m) (WriterT w n) (FocusingPlus w k) s t 
Functor (k (s, w)) => Functor (FocusingPlus w k s) 
(Functor (FocusingPlus w k s), Monoid w, Applicative (k (s, w))) => Applicative (FocusingPlus w k s) 

newtype FocusingOn f k s a Source

Used by Zoom to zoom into MaybeT or ListT

Constructors

FocusingOn 

Fields

unfocusingOn :: k (f s) a
 

Instances

(MonadState s (ListT m), MonadState t (ListT n), Zoom m n k s t) => Zoom (ListT m) (ListT n) (FocusingOn [] k) s t 
Functor (k (f s)) => Functor (FocusingOn f k s) 
(Functor (FocusingOn f k s), Applicative (k (f s))) => Applicative (FocusingOn f k s) 

newtype FocusingMay k s a Source

Used by Zoom to zoom into ErrorT

Constructors

FocusingMay 

Fields

unfocusingMay :: k (May s) a
 

Instances

(MonadState s (MaybeT m), MonadState t (MaybeT n), Zoom m n k s t) => Zoom (MaybeT m) (MaybeT n) (FocusingMay k) s t 
Functor (k (May s)) => Functor (FocusingMay k s) 
(Functor (FocusingMay k s), Applicative (k (May s))) => Applicative (FocusingMay k s) 

newtype FocusingErr e k s a Source

Used by Zoom to zoom into ErrorT

Constructors

FocusingErr 

Fields

unfocusingErr :: k (Err e s) a
 

Instances

(MonadState s (ErrorT e m), MonadState t (ErrorT e n), Error e, Zoom m n k s t) => Zoom (ErrorT e m) (ErrorT e n) (FocusingErr e k) s t 
Functor (k (Err e s)) => Functor (FocusingErr e k s) 
(Functor (FocusingErr e k s), Applicative (k (Err e s))) => Applicative (FocusingErr e k s) 

newtype Mutator a Source

Mutator is just a renamed Identity functor to give better error messages when someone attempts to use a getter as a setter.

Most user code will never need to see this type.

Constructors

Mutator 

Fields

runMutator :: a
 

newtype Bazaar a b t Source

This is used to characterize a Traversal.

a.k.a. indexed Cartesian store comonad, indexed Kleene store comonad, or an indexed FunList.

http://twanvl.nl/blog/haskell/non-regular1

Bazaar a b t is isomorphic to data Bazaar a b t = Buy t | Trade (Bazaar a b (b -> t)) a, and to exists s. (s, Traversal s t a b).

A Bazaar is like a Traversal that has already been applied to some structure.

Where a Context a b t holds an a and a function from b to t, a Bazaar a b t holds N as and a function from N bs to t.

Mnemonically, a Bazaar holds many stores and you can easily add more.

This is a final encoding of Bazaar.

Constructors

Bazaar 

Fields

runBazaar :: forall f. Applicative f => (a -> f b) -> f t
 

Instances

Functor (Bazaar a b) 
Functor (Bazaar a b) => Applicative (Bazaar a b) 
(Functor (Bazaar a b), ~ * a b) => Comonad (Bazaar a b) 
(Comonad (Bazaar a b), ~ * a b) => ComonadApply (Bazaar a b) 

bazaar :: Applicative f => (a -> f b) -> Bazaar a b t -> f tSource

Given an action to run for each matched pair, traverse a bazaar.

bazaar :: Traversal (Bazaar a b t) t a b

duplicateBazaar :: Bazaar a c t -> Bazaar a b (Bazaar b c t)Source

Bazaar is an indexed Comonad.

sell :: a -> Bazaar a b bSource

A trivial Bazaar.

newtype BazaarT a b g t Source

BazaarT is like Bazaar, except that it provides a questionable Gettable instance To protect this instance it relies on the soundness of another Gettable type, and usage conventions.

For example. This lets us write a suitably polymorphic and lazy taking, but there must be a better way!

Constructors

BazaarT 

Fields

runBazaarT :: forall f. Applicative f => (a -> f b) -> f t
 

Instances

Functor (BazaarT a b g) 
Functor (BazaarT a b g) => Applicative (BazaarT a b g) 
(Functor (BazaarT a b g), ~ * a b) => Comonad (BazaarT a b g) 
(Functor (BazaarT a b g), Gettable g) => Gettable (BazaarT a b g) 

bazaarT :: Applicative f => (a -> f b) -> BazaarT a b g t -> f tSource

Extract from a BazaarT.

bazaarT = flip runBazaarT

duplicateBazaarT :: BazaarT a c f t -> BazaarT a b f (BazaarT b c f t)Source

BazaarT is an indexed Comonad.

sellT :: a -> BazaarT a b f bSource

A trivial BazaarT.

data Context a b t Source

The indexed store can be used to characterize a Lens and is used by clone

Context a b t is isomorphic to newtype Context a b t = Context { runContext :: forall f. Functor f => (a -> f b) -> f t }, and to exists s. (s, Lens s t a b).

A Context is like a Lens that has already been applied to a some structure.

Constructors

Context (b -> t) a 

Instances

(Comonad (Context a b), ~ * a b) => ComonadStore a (Context a b) 
Functor (Context a b) 
(Functor (Context a b), ~ * a b) => Comonad (Context a b) 

data Max a Source

Used for maximumOf

Constructors

NoMax 
Max a 

Instances

Ord a => Monoid (Max a) 

getMax :: Max a -> Maybe aSource

Obtain the maximum

data Min a Source

Used for minimumOf

Constructors

NoMin 
Min a 

Instances

Ord a => Monoid (Min a) 

getMin :: Min a -> Maybe aSource

Obtain the minimum.

newtype Indexing f a Source

Applicative composition of State Int with a Functor, used by indexed

Constructors

Indexing 

Fields

runIndexing :: Int -> (f a, Int)
 

Overloadings

data Prismoid ab st whereSource

This data type is used to capture all of the information provided by the Prismatic class, so you can turn a Prism around into a Getter or otherwise muck around with its internals.

If you see a function that expects a Prismoid or APrism, it is probably just expecting a Prism.

Constructors

Prismoid :: Prismoid x x 
Prism :: (CoB x -> CoB y) -> (CoA y -> Either (CoB y) (CoA x)) -> Prismoid x y 

data Isoid ab st whereSource

Reify all of the information given to you by being Isomorphic.

Constructors

Isoid :: Isoid ab ab 
Iso :: (CoA y -> CoA x) -> (CoB x -> CoB y) -> Isoid x y 

newtype Indexed i a b Source

A function with access to a index. This constructor may be useful when you need to store a Indexable in a container to avoid ImpredicativeTypes.

Constructors

Indexed 

Fields

withIndex :: (i -> a) -> b
 

Instances

~ * i j => Indexable i (Indexed j)

Using an equality witness to avoid potential overlapping instances and aid dispatch.

type family CoA x :: *Source

Extract a from the type a -> f b

type family CoB x :: *Source

Extract b from the type a -> f b