lens-5.3.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-Inferred
Language | Haskell2010

Control.Lens.Internal.Context

Description

Synopsis

- class IndexedFunctor (w :: Type -> Type -> Type -> Type) where
  - ifmap :: (s -> t) -> w a b s -> w a b t
- class IndexedFunctor w => IndexedComonad (w :: Type -> Type -> Type -> Type) where
  - iextract :: w a a t -> t
  - iduplicate :: w a c t -> w a b (w b c t)
  - iextend :: (w b c t -> r) -> w a c t -> w a b r
- class IndexedComonad w => IndexedComonadStore (w :: Type -> Type -> Type -> Type) where
  - ipos :: w a c t -> a
  - ipeek :: c -> w a c t -> t
  - ipeeks :: (a -> c) -> w a c t -> t
  - iseek :: b -> w a c t -> w b c t
  - iseeks :: (a -> b) -> w a c t -> w b c t
  - iexperiment :: Functor f => (b -> f c) -> w b c t -> f t
  - context :: w a b t -> Context a b t
- class Corepresentable p => Sellable (p :: Type -> Type -> Type) (w :: Type -> Type -> Type -> Type) | w -> p where
  - sell :: p a (w a b b)
- data Context a b t = Context (b -> t) a
- type Context' a = Context a a
- newtype Pretext (p :: Type -> Type -> Type) a b t = Pretext {
  - runPretext :: forall (f :: Type -> Type). Functor f => p a (f b) -> f t
  }
- type Pretext' (p :: Type -> Type -> Type) a = Pretext p a a
- newtype PretextT (p :: Type -> Type -> Type) (g :: Type -> Type) a b t = PretextT {
  - runPretextT :: forall (f :: Type -> Type). Functor f => p a (f b) -> f t
  }
- type PretextT' (p :: Type -> Type -> Type) (g :: Type -> Type) a = PretextT p g a a

# Documentation

class IndexedFunctor (w :: Type -> Type -> Type -> Type) 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.

Methods

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

#### Instances

Instances details

IndexedFunctor Context # |
Instance details Defined in Control.Lens.Internal.Context Methods ifmap :: (s -> t) -> Context a b s -> Context a b t #
IndexedFunctor Mafic # |
Instance details Defined in Control.Lens.Internal.Magma Methods ifmap :: (s -> t) -> Mafic a b s -> Mafic a b t #
IndexedFunctor (Bazaar p) # |
Instance details Defined in Control.Lens.Internal.Bazaar Methods ifmap :: (s -> t) -> Bazaar p a b s -> Bazaar p a b t #
IndexedFunctor (Bazaar1 p) # |
Instance details Defined in Control.Lens.Internal.Bazaar Methods ifmap :: (s -> t) -> Bazaar1 p a b s -> Bazaar1 p a b t #
IndexedFunctor (Pretext p) # |
Instance details Defined in Control.Lens.Internal.Context Methods ifmap :: (s -> t) -> Pretext p a b s -> Pretext p a b t #
IndexedFunctor (Molten i) # |
Instance details Defined in Control.Lens.Internal.Magma Methods ifmap :: (s -> t) -> Molten i a b s -> Molten i a b t #
IndexedFunctor (BazaarT p g) # |
Instance details Defined in Control.Lens.Internal.Bazaar Methods ifmap :: (s -> t) -> BazaarT p g a b s -> BazaarT p g a b t #
IndexedFunctor (BazaarT1 p g) # |
Instance details Defined in Control.Lens.Internal.Bazaar Methods ifmap :: (s -> t) -> BazaarT1 p g a b s -> BazaarT1 p g a b t #
IndexedFunctor (PretextT p g) # |
Instance details Defined in Control.Lens.Internal.Context Methods ifmap :: (s -> t) -> PretextT p g a b s -> PretextT p g a b t #
IndexedFunctor (TakingWhile p f) # |
Instance details Defined in Control.Lens.Internal.Magma Methods ifmap :: (s -> t) -> TakingWhile p f a b s -> TakingWhile p f a b t #

class IndexedFunctor w => IndexedComonad (w :: Type -> Type -> Type -> Type) 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, (iduplicate | iextend)

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

Instances details

IndexedComonad Context # |
Instance details Defined in Control.Lens.Internal.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 (Bazaar p) # |
Instance details Defined in Control.Lens.Internal.Bazaar 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 #
Conjoined p => IndexedComonad (Bazaar1 p) # |
Instance details Defined in Control.Lens.Internal.Bazaar 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 (Pretext p) # |
Instance details Defined in Control.Lens.Internal.Context 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 #
IndexedComonad (Molten i) # |
Instance details Defined in Control.Lens.Internal.Magma 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 (BazaarT p g) # |
Instance details Defined in Control.Lens.Internal.Bazaar 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 #
Conjoined p => IndexedComonad (BazaarT1 p g) # |
Instance details Defined in Control.Lens.Internal.Bazaar 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 (PretextT p g) # |
Instance details Defined in Control.Lens.Internal.Context 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 #

class IndexedComonad w => IndexedComonadStore (w :: Type -> Type -> Type -> Type) 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

Instances details

IndexedComonadStore Context # |
Instance details Defined in Control.Lens.Internal.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) # |
Instance details Defined in Control.Lens.Internal.Context 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) # |
Instance details Defined in Control.Lens.Internal.Context 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 :: Type -> Type -> Type) (w :: Type -> Type -> Type -> Type) | w -> p where #

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

Methods

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

#### Instances

Instances details

Corepresentable p => Sellable p (Bazaar p) # |
Instance details Defined in Control.Lens.Internal.Bazaar Methods sell :: p a (Bazaar p a b b) #
Corepresentable p => Sellable p (Bazaar1 p) # |
Instance details Defined in Control.Lens.Internal.Bazaar Methods sell :: p a (Bazaar1 p a b b) #
Corepresentable p => Sellable p (Pretext p) # |
Instance details Defined in Control.Lens.Internal.Context Methods sell :: p a (Pretext p a b b) #
Corepresentable p => Sellable p (BazaarT p g) # |
Instance details Defined in Control.Lens.Internal.Bazaar Methods sell :: p a (BazaarT p g a b b) #
Corepresentable p => Sellable p (BazaarT1 p g) # |
Instance details Defined in Control.Lens.Internal.Bazaar Methods sell :: p a (BazaarT1 p g a b b) #
Corepresentable p => Sellable p (PretextT p g) # |
Instance details Defined in Control.Lens.Internal.Context Methods sell :: p a (PretextT p g a b b) #
Sellable (Indexed i) (Molten i) # |
Instance details Defined in Control.Lens.Internal.Magma Methods sell :: Indexed i a (Molten i a b b) #
Sellable (->) Context # |
Instance details Defined in Control.Lens.Internal.Context Methods sell :: a -> Context a b b #
Sellable (->) Mafic # |
Instance details Defined in Control.Lens.Internal.Magma Methods sell :: a -> Mafic 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

Instances details

IndexedComonad Context # |
Instance details Defined in Control.Lens.Internal.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 #
IndexedComonadStore Context # |
Instance details Defined in Control.Lens.Internal.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 #
IndexedFunctor Context # |
Instance details Defined in Control.Lens.Internal.Context Methods ifmap :: (s -> t) -> Context a b s -> Context a b t #
a ~ b => ComonadStore a (Context a b) # |
Instance details Defined in Control.Lens.Internal.Context Methods pos :: Context a b a0 -> a # peek :: a -> Context a b a0 -> a0 # peeks :: (a -> a) -> Context a b a0 -> a0 # seek :: a -> Context a b a0 -> Context a b a0 # seeks :: (a -> a) -> Context a b a0 -> Context a b a0 # experiment :: Functor f => (a -> f a) -> Context a b a0 -> f a0 #
a ~ b => Comonad (Context a b) # |
Instance details Defined in Control.Lens.Internal.Context Methods extract :: Context a b a0 -> a0 # duplicate :: Context a b a0 -> Context a b (Context a b a0) # extend :: (Context a b a0 -> b0) -> Context a b a0 -> Context a b b0 #
Functor (Context a b) # |
Instance details Defined in Control.Lens.Internal.Context Methods fmap :: (a0 -> b0) -> Context a b a0 -> Context a b b0 # (<$) :: a0 -> Context a b b0 -> Context a b a0 #
Sellable (->) Context # |
Instance details Defined in Control.Lens.Internal.Context Methods sell :: a -> Context a b b #

type Context' a = Context a a #

    type Context' a s = Context a a s

newtype Pretext (p :: Type -> Type -> Type) 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 :: Type -> Type). Functor f => p a (f b) -> f t

#### Instances

Instances details

Corepresentable p => Sellable p (Pretext p) # |
Instance details Defined in Control.Lens.Internal.Context Methods sell :: p a (Pretext p a b b) #
(a ~ b, Conjoined p) => ComonadStore a (Pretext p a b) # |
Instance details Defined in Control.Lens.Internal.Context Methods pos :: Pretext p a b a0 -> a # peek :: a -> Pretext p a b a0 -> a0 # peeks :: (a -> a) -> Pretext p a b a0 -> a0 # seek :: a -> Pretext p a b a0 -> Pretext p a b a0 # seeks :: (a -> a) -> Pretext p a b a0 -> Pretext p a b a0 # experiment :: Functor f => (a -> f a) -> Pretext p a b a0 -> f a0 #
Conjoined p => IndexedComonad (Pretext p) # |
Instance details Defined in Control.Lens.Internal.Context 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 => IndexedComonadStore (Pretext p) # |
Instance details Defined in Control.Lens.Internal.Context 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 #
IndexedFunctor (Pretext p) # |
Instance details Defined in Control.Lens.Internal.Context Methods ifmap :: (s -> t) -> Pretext p a b s -> Pretext p a b t #
(a ~ b, Conjoined p) => Comonad (Pretext p a b) # |
Instance details Defined in Control.Lens.Internal.Context Methods extract :: Pretext p a b a0 -> a0 # duplicate :: Pretext p a b a0 -> Pretext p a b (Pretext p a b a0) # extend :: (Pretext p a b a0 -> b0) -> Pretext p a b a0 -> Pretext p a b b0 #
Functor (Pretext p a b) # |
Instance details Defined in Control.Lens.Internal.Context Methods fmap :: (a0 -> b0) -> Pretext p a b a0 -> Pretext p a b b0 # (<$) :: a0 -> Pretext p a b b0 -> Pretext p a b a0 #

type Pretext' (p :: Type -> Type -> Type) a = Pretext p a a #

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

newtype PretextT (p :: Type -> Type -> Type) (g :: Type -> Type) 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 :: Type -> Type). Functor f => p a (f b) -> f t

#### Instances

Instances details

Corepresentable p => Sellable p (PretextT p g) # |
Instance details Defined in Control.Lens.Internal.Context Methods sell :: p a (PretextT p g a b b) #
(a ~ b, Conjoined p) => ComonadStore a (PretextT p g a b) # |
Instance details Defined in Control.Lens.Internal.Context Methods pos :: PretextT p g a b a0 -> a # peek :: a -> PretextT p g a b a0 -> a0 # peeks :: (a -> a) -> PretextT p g a b a0 -> a0 # seek :: a -> PretextT p g a b a0 -> PretextT p g a b a0 # seeks :: (a -> a) -> PretextT p g a b a0 -> PretextT p g a b a0 # experiment :: Functor f => (a -> f a) -> PretextT p g a b a0 -> f a0 #
Conjoined p => IndexedComonad (PretextT p g) # |
Instance details Defined in Control.Lens.Internal.Context 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 => IndexedComonadStore (PretextT p g) # |
Instance details Defined in Control.Lens.Internal.Context 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 #
IndexedFunctor (PretextT p g) # |
Instance details Defined in Control.Lens.Internal.Context Methods ifmap :: (s -> t) -> PretextT p g a b s -> PretextT p g a b t #
(Profunctor p, Contravariant g) => Contravariant (PretextT p g a b) # |
Instance details Defined in Control.Lens.Internal.Context Methods contramap :: (a' -> a0) -> PretextT p g a b a0 -> PretextT p g a b a' # (>$) :: b0 -> PretextT p g a b b0 -> PretextT p g a b a0 #
(a ~ b, Conjoined p) => Comonad (PretextT p g a b) # |
Instance details Defined in Control.Lens.Internal.Context Methods extract :: PretextT p g a b a0 -> a0 # duplicate :: PretextT p g a b a0 -> PretextT p g a b (PretextT p g a b a0) # extend :: (PretextT p g a b a0 -> b0) -> PretextT p g a b a0 -> PretextT p g a b b0 #
Functor (PretextT p g a b) # |
Instance details Defined in Control.Lens.Internal.Context Methods fmap :: (a0 -> b0) -> PretextT p g a b a0 -> PretextT p g a b b0 # (<$) :: a0 -> PretextT p g a b b0 -> PretextT p g a b a0 #

type PretextT' (p :: Type -> Type -> Type) (g :: Type -> Type) a = PretextT p g a a #

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