lens-4.15.3: Lenses, Folds and Traversals

Copyright | (C) 2012-2016 Edward Kmett
License | BSD-style (see the file LICENSE)
Maintainer | Edward Kmett <ekmett@gmail.com>
Stability | experimental
Portability | non-portable
Safe Haskell | Safe
Language | Haskell98

Control.Lens.Internal.Context

Description

Synopsis

- class IndexedFunctor w where
- class IndexedFunctor w => IndexedComonad w where
- class IndexedComonad w => IndexedComonadStore w where
- class Corepresentable p => Sellable p w | w -> p where
- data Context a b t = Context (b -> t) a
- type Context' a = Context a a
- newtype Pretext p a b t = Pretext {
  - runPretext :: forall f. Functor f => p a (f b) -> f t
  }
- type Pretext' p a = Pretext p a a
- newtype PretextT p g a b t = PretextT {
  - runPretextT :: forall f. Functor f => p a (f b) -> f t
  }
- type PretextT' p g a = PretextT p g a a

# Documentation

class IndexedFunctor w where #

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 #

Instances

IndexedFunctor Context # |
Methods ifmap :: (s -> t) -> Context a b s -> Context a b t #
IndexedFunctor Mafic # |
Methods ifmap :: (s -> t) -> Mafic a b s -> Mafic a b t #
IndexedFunctor (Pretext p) # |
Methods ifmap :: (s -> t) -> Pretext p a b s -> Pretext p a b t #
IndexedFunctor (Bazaar1 p) # |
Methods ifmap :: (s -> t) -> Bazaar1 p a b s -> Bazaar1 p a b t #
IndexedFunctor (Bazaar p) # |
Methods ifmap :: (s -> t) -> Bazaar p a b s -> Bazaar p a b t #
IndexedFunctor (Molten i) # |
Methods ifmap :: (s -> t) -> Molten i a b s -> Molten i a b t #
IndexedFunctor (PretextT p g) # |
Methods ifmap :: (s -> t) -> PretextT p g a b s -> PretextT p g a b t #
IndexedFunctor (BazaarT1 p g) # |
Methods ifmap :: (s -> t) -> BazaarT1 p g a b s -> BazaarT1 p g a b t #
IndexedFunctor (BazaarT p g) # |
Methods ifmap :: (s -> t) -> BazaarT p g a b s -> BazaarT p g a b t #
IndexedFunctor (TakingWhile p f) # |
Methods ifmap :: (s -> t) -> TakingWhile p f a b s -> TakingWhile p f a b t #

class IndexedFunctor w => IndexedComonad w where #

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 #

extract from an indexed comonadic value when the indices match.

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

duplicate an indexed comonadic value splitting the index.

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

extend a indexed comonadic computation splitting the index.

Instances

IndexedComonad Context # |
Methods iextract :: Context a a t -> t # iduplicate :: Context a c t -> Context a b (Context b c t) # iextend :: (Context b c t -> r) -> Context a c t -> Context a b r #
Conjoined p => IndexedComonad (Pretext p) # |
Methods iextract :: Pretext p a a t -> t # iduplicate :: Pretext p a c t -> Pretext p a b (Pretext p b c t) # iextend :: (Pretext p b c t -> r) -> Pretext p a c t -> Pretext p a b r #
Conjoined p => IndexedComonad (Bazaar1 p) # |
Methods iextract :: Bazaar1 p a a t -> t # iduplicate :: Bazaar1 p a c t -> Bazaar1 p a b (Bazaar1 p b c t) # iextend :: (Bazaar1 p b c t -> r) -> Bazaar1 p a c t -> Bazaar1 p a b r #
Conjoined p => IndexedComonad (Bazaar p) # |
Methods iextract :: Bazaar p a a t -> t # iduplicate :: Bazaar p a c t -> Bazaar p a b (Bazaar p b c t) # iextend :: (Bazaar p b c t -> r) -> Bazaar p a c t -> Bazaar p a b r #
IndexedComonad (Molten i) # |
Methods iextract :: Molten i a a t -> t # iduplicate :: Molten i a c t -> Molten i a b (Molten i b c t) # iextend :: (Molten i b c t -> r) -> Molten i a c t -> Molten i a b r #
Conjoined p => IndexedComonad (PretextT p g) # |
Methods iextract :: PretextT p g a a t -> t # iduplicate :: PretextT p g a c t -> PretextT p g a b (PretextT p g b c t) # iextend :: (PretextT p g b c t -> r) -> PretextT p g a c t -> PretextT p g a b r #
Conjoined p => IndexedComonad (BazaarT1 p g) # |
Methods iextract :: BazaarT1 p g a a t -> t # iduplicate :: BazaarT1 p g a c t -> BazaarT1 p g a b (BazaarT1 p g b c t) # iextend :: (BazaarT1 p g b c t -> r) -> BazaarT1 p g a c t -> BazaarT1 p g a b r #
Conjoined p => IndexedComonad (BazaarT p g) # |
Methods iextract :: BazaarT p g a a t -> t # iduplicate :: BazaarT p g a c t -> BazaarT p g a b (BazaarT p g b c t) # iextend :: (BazaarT p g b c t -> r) -> BazaarT p g a c t -> BazaarT p g a b r #

class IndexedComonad w => IndexedComonadStore w where #

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 #

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

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

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

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

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

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

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

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

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

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

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

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

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

Instances

IndexedComonadStore Context # |
Methods ipos :: Context a c t -> a # ipeek :: c -> Context a c t -> t # ipeeks :: (a -> c) -> Context a c t -> t # iseek :: b -> Context a c t -> Context b c t # iseeks :: (a -> b) -> Context a c t -> Context b c t # iexperiment :: Functor f => (b -> f c) -> Context b c t -> f t # context :: Context a b t -> Context a b t #
Conjoined p => IndexedComonadStore (Pretext p) # |
Methods ipos :: Pretext p a c t -> a # ipeek :: c -> Pretext p a c t -> t # ipeeks :: (a -> c) -> Pretext p a c t -> t # iseek :: b -> Pretext p a c t -> Pretext p b c t # iseeks :: (a -> b) -> Pretext p a c t -> Pretext p b c t # iexperiment :: Functor f => (b -> f c) -> Pretext p b c t -> f t # context :: Pretext p a b t -> Context a b t #
Conjoined p => IndexedComonadStore (PretextT p g) # |
Methods ipos :: PretextT p g a c t -> a # ipeek :: c -> PretextT p g a c t -> t # ipeeks :: (a -> c) -> PretextT p g a c t -> t # iseek :: b -> PretextT p g a c t -> PretextT p g b c t # iseeks :: (a -> b) -> PretextT p g a c t -> PretextT p g b c t # iexperiment :: Functor f => (b -> f c) -> PretextT p g b c t -> f t # context :: PretextT p g a b t -> Context a b t #

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

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) #

Instances

Sellable (->) Context # |
Methods sell :: a -> Context a b b #
Sellable (->) Mafic # |
Methods sell :: a -> Mafic a b b #
Corepresentable p => Sellable p (Pretext p) # |
Methods sell :: p a (Pretext p a b b) #
Corepresentable p => Sellable p (Bazaar1 p) # |
Methods sell :: p a (Bazaar1 p a b b) #
Corepresentable p => Sellable p (Bazaar p) # |
Methods sell :: p a (Bazaar p a b b) #
Corepresentable p => Sellable p (PretextT p g) # |
Methods sell :: p a (PretextT p g a b b) #
Corepresentable p => Sellable p (BazaarT1 p g) # |
Methods sell :: p a (BazaarT1 p g a b b) #
Corepresentable p => Sellable p (BazaarT p g) # |
Methods sell :: p a (BazaarT p g a b b) #
Sellable (Indexed i) (Molten i) # |
Methods sell :: Indexed i a (Molten i a b b) #

data Context a b t #

The indexed store can be used to characterize a `Lens` and is used by `cloneLens`.

``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 # |
Methods ipos :: Context a c t -> a # ipeek :: c -> Context a c t -> t # ipeeks :: (a -> c) -> Context a c t -> t # iseek :: b -> Context a c t -> Context b c t # iseeks :: (a -> b) -> Context a c t -> Context b c t # iexperiment :: Functor f => (b -> f c) -> Context b c t -> f t # context :: Context a b t -> Context a b t #
IndexedComonad Context # |
Methods iextract :: Context a a t -> t # iduplicate :: Context a c t -> Context a b (Context b c t) # iextend :: (Context b c t -> r) -> Context a c t -> Context a b r #
IndexedFunctor Context # |
Methods ifmap :: (s -> t) -> Context a b s -> Context a b t #
Sellable (->) Context # |
Methods sell :: a -> Context a b b #
(~) * a b => ComonadStore a (Context a b) # |
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) # |
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) # |
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 #

    type Context' a s = Context a a s

newtype Pretext p a b t #

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 runPretext :: forall f. Functor f => p a (f b) -> f t

Instances

Corepresentable p => Sellable p (Pretext p) # |
Methods sell :: p a (Pretext p a b b) #
((~) * a b, Conjoined p) => ComonadStore a (Pretext p a b) # |
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) # |
Methods ipos :: Pretext p a c t -> a # ipeek :: c -> Pretext p a c t -> t # ipeeks :: (a -> c) -> Pretext p a c t -> t # iseek :: b -> Pretext p a c t -> Pretext p b c t # iseeks :: (a -> b) -> Pretext p a c t -> Pretext p b c t # iexperiment :: Functor f => (b -> f c) -> Pretext p b c t -> f t # context :: Pretext p a b t -> Context a b t #
Conjoined p => IndexedComonad (Pretext p) # |
Methods iextract :: Pretext p a a t -> t # iduplicate :: Pretext p a c t -> Pretext p a b (Pretext p b c t) # iextend :: (Pretext p b c t -> r) -> Pretext p a c t -> Pretext p a b r #
IndexedFunctor (Pretext p) # |
Methods ifmap :: (s -> t) -> Pretext p a b s -> Pretext p a b t #
Functor (Pretext p a b) # |
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) # |
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 #

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

newtype PretextT p g a b t #

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 runPretextT :: forall f. Functor f => p a (f b) -> f t

Instances

Corepresentable p => Sellable p (PretextT p g) # |
Methods sell :: p a (PretextT p g a b b) #
((~) * a b, Conjoined p) => ComonadStore a (PretextT p g a b) # |
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) # |
Methods ipos :: PretextT p g a c t -> a # ipeek :: c -> PretextT p g a c t -> t # ipeeks :: (a -> c) -> PretextT p g a c t -> t # iseek :: b -> PretextT p g a c t -> PretextT p g b c t # iseeks :: (a -> b) -> PretextT p g a c t -> PretextT p g b c t # iexperiment :: Functor f => (b -> f c) -> PretextT p g b c t -> f t # context :: PretextT p g a b t -> Context a b t #
Conjoined p => IndexedComonad (PretextT p g) # |
Methods iextract :: PretextT p g a a t -> t # iduplicate :: PretextT p g a c t -> PretextT p g a b (PretextT p g b c t) # iextend :: (PretextT p g b c t -> r) -> PretextT p g a c t -> PretextT p g a b r #
IndexedFunctor (PretextT p g) # |
Methods ifmap :: (s -> t) -> PretextT p g a b s -> PretextT p g a b t #
Functor (PretextT p g a b) # |
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) # |
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) # |
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 #

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