lens-4.13: Lenses, Folds and Traversals

Copyright | (C) 2012-2015 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.Magma

Contents

- Magma
- Molten
- Mafic
- TakingWhile

Description

Synopsis

- data Magma i t b a where
  - MagmaAp :: Magma i (x -> y) b a -> Magma i x b a -> Magma i y b a
  - MagmaPure :: x -> Magma i x b a
  - MagmaFmap :: (x -> y) -> Magma i x b a -> Magma i y b a
  - Magma :: i -> a -> Magma i b b a
- runMagma :: Magma i t a a -> t
- newtype Molten i a b t = Molten {
  - runMolten :: Magma i t b a
  }
- data Mafic a b t = Mafic Int (Int -> Magma Int t b a)
- runMafic :: Mafic a b t -> Magma Int t b a
- data TakingWhile p g a b t = TakingWhile Bool t (Bool -> Magma () t b (Corep p a))
- runTakingWhile :: TakingWhile p f a b t -> Magma () t b (Corep p a)

# Magma

data Magma i t b a where Source

This provides a way to peek at the internal structure of a `Traversal` or `IndexedTraversal`

Constructors

MagmaAp :: Magma i (x -> y) b a -> Magma i x b a -> Magma i y b a |
MagmaPure :: x -> Magma i x b a |
MagmaFmap :: (x -> y) -> Magma i x b a -> Magma i y b a |
Magma :: i -> a -> Magma i b b a |

Instances

TraversableWithIndex i (Magma i t b) Source |
FoldableWithIndex i (Magma i t b) Source |
FunctorWithIndex i (Magma i t b) Source |
Functor (Magma i t b) Source |
Foldable (Magma i t b) Source |
Traversable (Magma i t b) Source |
(Show i, Show a) => Show (Magma i t b a) Source |

runMagma :: Magma i t a a -> t Source

Run a `Magma` where all the individual leaves have been converted to the expected type

# Molten

newtype Molten i a b t Source

This is a a non-reassociating initially encoded version of `Bazaar`.

Constructors

Molten |

Fields

runMolten :: Magma i t b a

Instances

IndexedComonad (Molten i) Source |
IndexedFunctor (Molten i) Source |
Sellable (Indexed i) (Molten i) Source |
Bizarre (Indexed i) (Molten i) Source |
Functor (Molten i a b) Source |
Applicative (Molten i a b) Source |
(~) * a b => Comonad (Molten i a b) Source |
Apply (Molten i a b) Source |

# Mafic

data Mafic a b t Source

This is used to generate an indexed magma from an unindexed source

By constructing it this way we avoid infinite reassociations in sums where possible.

Constructors

Mafic Int (Int -> Magma Int t b a) |

Instances

IndexedFunctor Mafic Source |
Sellable (->) Mafic Source |
Bizarre (Indexed Int) Mafic Source |
Functor (Mafic a b) Source |
Applicative (Mafic a b) Source |
Apply (Mafic a b) Source |

runMafic :: Mafic a b t -> Magma Int t b a Source

Generate a `Magma` using from a prefix sum.

# TakingWhile

data TakingWhile p g a b t Source

This is used to generate an indexed magma from an unindexed source

By constructing it this way we avoid infinite reassociations where possible.

In ``TakingWhile` p g a b t`, `g` has a `nominal` role to avoid exposing an illegal _|_ via `Contravariant`, while the remaining arguments are degraded to a `nominal` role by the invariants of `Magma`

Constructors

TakingWhile Bool t (Bool -> Magma () t b (Corep p a)) |

Instances

Corepresentable p => Bizarre p (TakingWhile p g) Source |
IndexedFunctor (TakingWhile p f) Source |
Functor (TakingWhile p f a b) Source |
Applicative (TakingWhile p f a b) Source |
Contravariant f => Contravariant (TakingWhile p f a b) Source |
Apply (TakingWhile p f a b) Source |

runTakingWhile :: TakingWhile p f a b t -> Magma () t b (Corep p a) Source

Generate a `Magma` with leaves only while the predicate holds from left to right.