lens-4.15.1: Lenses, Folds and Traversals

Copyright(C) 2012-2016 Edward Kmett
LicenseBSD-style (see the file LICENSE)
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell98

Control.Lens.Internal.Context

Description

 

Synopsis

Documentation

class IndexedFunctor w where Source #

This is a Bob Atkey -style 2-argument indexed functor.

It exists as a superclass for IndexedComonad and expresses the functoriality of an IndexedComonad in its third argument.

Minimal complete definition

ifmap

Methods

ifmap :: (s -> t) -> w a b s -> w a b t Source #

Instances

IndexedFunctor Context Source # 

Methods

ifmap :: (s -> t) -> Context a b s -> Context a b t Source #

IndexedFunctor Mafic Source # 

Methods

ifmap :: (s -> t) -> Mafic a b s -> Mafic a b t Source #

IndexedFunctor (Pretext p) Source # 

Methods

ifmap :: (s -> t) -> Pretext p a b s -> Pretext p a b t Source #

IndexedFunctor (Bazaar1 p) Source # 

Methods

ifmap :: (s -> t) -> Bazaar1 p a b s -> Bazaar1 p a b t Source #

IndexedFunctor (Bazaar p) Source # 

Methods

ifmap :: (s -> t) -> Bazaar p a b s -> Bazaar p a b t Source #

IndexedFunctor (Molten i) Source # 

Methods

ifmap :: (s -> t) -> Molten i a b s -> Molten i a b t Source #

IndexedFunctor (PretextT p g) Source # 

Methods

ifmap :: (s -> t) -> PretextT p g a b s -> PretextT p g a b t Source #

IndexedFunctor (BazaarT1 p g) Source # 

Methods

ifmap :: (s -> t) -> BazaarT1 p g a b s -> BazaarT1 p g a b t Source #

IndexedFunctor (BazaarT p g) Source # 

Methods

ifmap :: (s -> t) -> BazaarT p g a b s -> BazaarT p g a b t Source #

IndexedFunctor (TakingWhile p f) Source # 

Methods

ifmap :: (s -> t) -> TakingWhile p f a b s -> TakingWhile p f a b t Source #

class IndexedFunctor w => IndexedComonad w where Source #

This is a Bob Atkey -style 2-argument indexed comonad.

It exists as a superclass for IndexedComonad and expresses the functoriality of an IndexedComonad in its third argument.

The notion of indexed monads is covered in more depth in Bob Atkey's "Parameterized Notions of Computation" http://bentnib.org/paramnotions-jfp.pdf and that construction is dualized here.

Minimal complete definition

iextract

Methods

iextract :: w a a t -> t Source #

extract from an indexed comonadic value when the indices match.

iduplicate :: w a c t -> w a b (w b c t) Source #

duplicate an indexed comonadic value splitting the index.

iextend :: (w b c t -> r) -> w a c t -> w a b r Source #

extend a indexed comonadic computation splitting the index.

Instances

IndexedComonad Context Source # 

Methods

iextract :: Context a a t -> t Source #

iduplicate :: Context a c t -> Context a b (Context b c t) Source #

iextend :: (Context b c t -> r) -> Context a c t -> Context a b r Source #

Conjoined p => IndexedComonad (Pretext p) Source # 

Methods

iextract :: Pretext p a a t -> t Source #

iduplicate :: Pretext p a c t -> Pretext p a b (Pretext p b c t) Source #

iextend :: (Pretext p b c t -> r) -> Pretext p a c t -> Pretext p a b r Source #

Conjoined p => IndexedComonad (Bazaar1 p) Source # 

Methods

iextract :: Bazaar1 p a a t -> t Source #

iduplicate :: Bazaar1 p a c t -> Bazaar1 p a b (Bazaar1 p b c t) Source #

iextend :: (Bazaar1 p b c t -> r) -> Bazaar1 p a c t -> Bazaar1 p a b r Source #

Conjoined p => IndexedComonad (Bazaar p) Source # 

Methods

iextract :: Bazaar p a a t -> t Source #

iduplicate :: Bazaar p a c t -> Bazaar p a b (Bazaar p b c t) Source #

iextend :: (Bazaar p b c t -> r) -> Bazaar p a c t -> Bazaar p a b r Source #

IndexedComonad (Molten i) Source # 

Methods

iextract :: Molten i a a t -> t Source #

iduplicate :: Molten i a c t -> Molten i a b (Molten i b c t) Source #

iextend :: (Molten i b c t -> r) -> Molten i a c t -> Molten i a b r Source #

Conjoined p => IndexedComonad (PretextT p g) Source # 

Methods

iextract :: PretextT p g a a t -> t Source #

iduplicate :: PretextT p g a c t -> PretextT p g a b (PretextT p g b c t) Source #

iextend :: (PretextT p g b c t -> r) -> PretextT p g a c t -> PretextT p g a b r Source #

Conjoined p => IndexedComonad (BazaarT1 p g) Source # 

Methods

iextract :: BazaarT1 p g a a t -> t Source #

iduplicate :: BazaarT1 p g a c t -> BazaarT1 p g a b (BazaarT1 p g b c t) Source #

iextend :: (BazaarT1 p g b c t -> r) -> BazaarT1 p g a c t -> BazaarT1 p g a b r Source #

Conjoined p => IndexedComonad (BazaarT p g) Source # 

Methods

iextract :: BazaarT p g a a t -> t Source #

iduplicate :: BazaarT p g a c t -> BazaarT p g a b (BazaarT p g b c t) Source #

iextend :: (BazaarT p g b c t -> r) -> BazaarT p g a c t -> BazaarT p g a b r Source #

class IndexedComonad w => IndexedComonadStore w where Source #

This is an indexed analogue to ComonadStore for when you are working with an IndexedComonad.

Minimal complete definition

ipos, iseek, iseeks

Methods

ipos :: w a c t -> a Source #

This is the generalization of pos to an indexed comonad store.

ipeek :: c -> w a c t -> t Source #

This is the generalization of peek to an indexed comonad store.

ipeeks :: (a -> c) -> w a c t -> t Source #

This is the generalization of peeks to an indexed comonad store.

iseek :: b -> w a c t -> w b c t Source #

This is the generalization of seek to an indexed comonad store.

iseeks :: (a -> b) -> w a c t -> w b c t Source #

This is the generalization of seeks to an indexed comonad store.

iexperiment :: Functor f => (b -> f c) -> w b c t -> f t Source #

This is the generalization of experiment to an indexed comonad store.

context :: w a b t -> Context a b t Source #

We can always forget the rest of the structure of w and obtain a simpler indexed comonad store model called Context.

Instances

IndexedComonadStore Context Source # 

Methods

ipos :: Context a c t -> a Source #

ipeek :: c -> Context a c t -> t Source #

ipeeks :: (a -> c) -> Context a c t -> t Source #

iseek :: b -> Context a c t -> Context b c t Source #

iseeks :: (a -> b) -> Context a c t -> Context b c t Source #

iexperiment :: Functor f => (b -> f c) -> Context b c t -> f t Source #

context :: Context a b t -> Context a b t Source #

Conjoined p => IndexedComonadStore (Pretext p) Source # 

Methods

ipos :: Pretext p a c t -> a Source #

ipeek :: c -> Pretext p a c t -> t Source #

ipeeks :: (a -> c) -> Pretext p a c t -> t Source #

iseek :: b -> Pretext p a c t -> Pretext p b c t Source #

iseeks :: (a -> b) -> Pretext p a c t -> Pretext p b c t Source #

iexperiment :: Functor f => (b -> f c) -> Pretext p b c t -> f t Source #

context :: Pretext p a b t -> Context a b t Source #

Conjoined p => IndexedComonadStore (PretextT p g) Source # 

Methods

ipos :: PretextT p g a c t -> a Source #

ipeek :: c -> PretextT p g a c t -> t Source #

ipeeks :: (a -> c) -> PretextT p g a c t -> t Source #

iseek :: b -> PretextT p g a c t -> PretextT p g b c t Source #

iseeks :: (a -> b) -> PretextT p g a c t -> PretextT p g b c t Source #

iexperiment :: Functor f => (b -> f c) -> PretextT p g b c t -> f t Source #

context :: PretextT p g a b t -> Context a b t Source #

class Corepresentable p => Sellable p w | w -> p where Source #

This is used internally to construct a Bazaar, Context or Pretext from a singleton value.

Minimal complete definition

sell

Methods

sell :: p a (w a b b) Source #

Instances

Sellable (->) Context Source # 

Methods

sell :: a -> Context a b b Source #

Sellable (->) Mafic Source # 

Methods

sell :: a -> Mafic a b b Source #

Corepresentable p => Sellable p (Pretext p) Source # 

Methods

sell :: p a (Pretext p a b b) Source #

Corepresentable p => Sellable p (Bazaar1 p) Source # 

Methods

sell :: p a (Bazaar1 p a b b) Source #

Corepresentable p => Sellable p (Bazaar p) Source # 

Methods

sell :: p a (Bazaar p a b b) Source #

Corepresentable p => Sellable p (PretextT p g) Source # 

Methods

sell :: p a (PretextT p g a b b) Source #

Corepresentable p => Sellable p (BazaarT1 p g) Source # 

Methods

sell :: p a (BazaarT1 p g a b b) Source #

Corepresentable p => Sellable p (BazaarT p g) Source # 

Methods

sell :: p a (BazaarT p g a b b) Source #

Sellable (Indexed i) (Molten i) Source # 

Methods

sell :: Indexed i a (Molten i a b b) Source #

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

IndexedComonadStore Context Source # 

Methods

ipos :: Context a c t -> a Source #

ipeek :: c -> Context a c t -> t Source #

ipeeks :: (a -> c) -> Context a c t -> t Source #

iseek :: b -> Context a c t -> Context b c t Source #

iseeks :: (a -> b) -> Context a c t -> Context b c t Source #

iexperiment :: Functor f => (b -> f c) -> Context b c t -> f t Source #

context :: Context a b t -> Context a b t Source #

IndexedComonad Context Source # 

Methods

iextract :: Context a a t -> t Source #

iduplicate :: Context a c t -> Context a b (Context b c t) Source #

iextend :: (Context b c t -> r) -> Context a c t -> Context a b r Source #

IndexedFunctor Context Source # 

Methods

ifmap :: (s -> t) -> Context a b s -> Context a b t Source #

Sellable (->) Context Source # 

Methods

sell :: a -> Context a b b Source #

(~) * a b => ComonadStore a (Context a b) Source # 

Methods

pos :: Context a b a -> a #

peek :: a -> Context a b a -> a #

peeks :: (a -> a) -> Context a b a -> a #

seek :: a -> Context a b a -> Context a b a #

seeks :: (a -> a) -> Context a b a -> Context a b a #

experiment :: Functor f => (a -> f a) -> Context a b a -> f a #

Functor (Context a b) Source # 

Methods

fmap :: (a -> b) -> Context a b a -> Context a b b #

(<$) :: a -> Context a b b -> Context a b a #

(~) * a b => Comonad (Context a b) Source # 

Methods

extract :: Context a b a -> a #

duplicate :: Context a b a -> Context a b (Context a b a) #

extend :: (Context a b a -> b) -> Context a b a -> Context a b b #

type Context' a = Context a a Source #

type Context' a s = Context a a s

newtype Pretext p a b t Source #

This is a generalized form of Context that can be repeatedly cloned with less impact on its performance, and which permits the use of an arbitrary Conjoined Profunctor

Constructors

Pretext 

Fields

Instances

Corepresentable p => Sellable p (Pretext p) Source # 

Methods

sell :: p a (Pretext p a b b) Source #

((~) * a b, Conjoined p) => ComonadStore a (Pretext p a b) Source # 

Methods

pos :: Pretext p a b a -> a #

peek :: a -> Pretext p a b a -> a #

peeks :: (a -> a) -> Pretext p a b a -> a #

seek :: a -> Pretext p a b a -> Pretext p a b a #

seeks :: (a -> a) -> Pretext p a b a -> Pretext p a b a #

experiment :: Functor f => (a -> f a) -> Pretext p a b a -> f a #

Conjoined p => IndexedComonadStore (Pretext p) Source # 

Methods

ipos :: Pretext p a c t -> a Source #

ipeek :: c -> Pretext p a c t -> t Source #

ipeeks :: (a -> c) -> Pretext p a c t -> t Source #

iseek :: b -> Pretext p a c t -> Pretext p b c t Source #

iseeks :: (a -> b) -> Pretext p a c t -> Pretext p b c t Source #

iexperiment :: Functor f => (b -> f c) -> Pretext p b c t -> f t Source #

context :: Pretext p a b t -> Context a b t Source #

Conjoined p => IndexedComonad (Pretext p) Source # 

Methods

iextract :: Pretext p a a t -> t Source #

iduplicate :: Pretext p a c t -> Pretext p a b (Pretext p b c t) Source #

iextend :: (Pretext p b c t -> r) -> Pretext p a c t -> Pretext p a b r Source #

IndexedFunctor (Pretext p) Source # 

Methods

ifmap :: (s -> t) -> Pretext p a b s -> Pretext p a b t Source #

Functor (Pretext p a b) Source # 

Methods

fmap :: (a -> b) -> Pretext p a b a -> Pretext p a b b #

(<$) :: a -> Pretext p a b b -> Pretext p a b a #

((~) * a b, Conjoined p) => Comonad (Pretext p a b) Source # 

Methods

extract :: Pretext p a b a -> a #

duplicate :: Pretext p a b a -> Pretext p a b (Pretext p a b a) #

extend :: (Pretext p a b a -> b) -> Pretext p a b a -> Pretext p a b b #

type Pretext' p a = Pretext p a a Source #

type Pretext' p a s = Pretext p a a s

newtype PretextT p g a b t Source #

This is a generalized form of Context that can be repeatedly cloned with less impact on its performance, and which permits the use of an arbitrary Conjoined Profunctor.

The extra phantom Functor is used to let us lie and claim Getter-compatibility under limited circumstances. This is used internally to permit a number of combinators to gracefully degrade when applied to a Fold or Getter.

Constructors

PretextT 

Fields

Instances

Corepresentable p => Sellable p (PretextT p g) Source # 

Methods

sell :: p a (PretextT p g a b b) Source #

((~) * a b, Conjoined p) => ComonadStore a (PretextT p g a b) Source # 

Methods

pos :: PretextT p g a b a -> a #

peek :: a -> PretextT p g a b a -> a #

peeks :: (a -> a) -> PretextT p g a b a -> a #

seek :: a -> PretextT p g a b a -> PretextT p g a b a #

seeks :: (a -> a) -> PretextT p g a b a -> PretextT p g a b a #

experiment :: Functor f => (a -> f a) -> PretextT p g a b a -> f a #

Conjoined p => IndexedComonadStore (PretextT p g) Source # 

Methods

ipos :: PretextT p g a c t -> a Source #

ipeek :: c -> PretextT p g a c t -> t Source #

ipeeks :: (a -> c) -> PretextT p g a c t -> t Source #

iseek :: b -> PretextT p g a c t -> PretextT p g b c t Source #

iseeks :: (a -> b) -> PretextT p g a c t -> PretextT p g b c t Source #

iexperiment :: Functor f => (b -> f c) -> PretextT p g b c t -> f t Source #

context :: PretextT p g a b t -> Context a b t Source #

Conjoined p => IndexedComonad (PretextT p g) Source # 

Methods

iextract :: PretextT p g a a t -> t Source #

iduplicate :: PretextT p g a c t -> PretextT p g a b (PretextT p g b c t) Source #

iextend :: (PretextT p g b c t -> r) -> PretextT p g a c t -> PretextT p g a b r Source #

IndexedFunctor (PretextT p g) Source # 

Methods

ifmap :: (s -> t) -> PretextT p g a b s -> PretextT p g a b t Source #

Functor (PretextT p g a b) Source # 

Methods

fmap :: (a -> b) -> PretextT p g a b a -> PretextT p g a b b #

(<$) :: a -> PretextT p g a b b -> PretextT p g a b a #

(Profunctor p, Contravariant g) => Contravariant (PretextT p g a b) Source # 

Methods

contramap :: (a -> b) -> PretextT p g a b b -> PretextT p g a b a #

(>$) :: b -> PretextT p g a b b -> PretextT p g a b a #

((~) * a b, Conjoined p) => Comonad (PretextT p g a b) Source # 

Methods

extract :: PretextT p g a b a -> a #

duplicate :: PretextT p g a b a -> PretextT p g a b (PretextT p g a b a) #

extend :: (PretextT p g a b a -> b) -> PretextT p g a b a -> PretextT p g a b b #

type PretextT' p g a = PretextT p g a a Source #

type PretextT' p g a s = PretextT p g a a s