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

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) # |
Methods itraverse :: Applicative f => (i -> a -> f b) -> Magma i t b a -> f (Magma i t b b) # itraversed :: (Indexable i p, Applicative f) => p a (f b) -> Magma i t b a -> f (Magma i t b b) #
FoldableWithIndex i (Magma i t b) # |
Methods ifoldMap :: Monoid m => (i -> a -> m) -> Magma i t b a -> m # ifolded :: (Indexable i p, Contravariant f, Applicative f) => p a (f a) -> Magma i t b a -> f (Magma i t b a) # ifoldr :: (i -> a -> b -> b) -> b -> Magma i t b a -> b # ifoldl :: (i -> b -> a -> b) -> b -> Magma i t b a -> b # ifoldr' :: (i -> a -> b -> b) -> b -> Magma i t b a -> b # ifoldl' :: (i -> b -> a -> b) -> b -> Magma i t b a -> b #
FunctorWithIndex i (Magma i t b) # |
Methods imap :: (i -> a -> b) -> Magma i t b a -> Magma i t b b # imapped :: (Indexable i p, Settable f) => p a (f b) -> Magma i t b a -> f (Magma i t b b) #
Functor (Magma i t b) # |
Methods fmap :: (a -> b) -> Magma i t b a -> Magma i t b b # (<$) :: a -> Magma i t b b -> Magma i t b a #
Foldable (Magma i t b) # |
Methods fold :: Monoid m => Magma i t b m -> m # foldMap :: Monoid m => (a -> m) -> Magma i t b a -> m # foldr :: (a -> b -> b) -> b -> Magma i t b a -> b # foldr' :: (a -> b -> b) -> b -> Magma i t b a -> b # foldl :: (b -> a -> b) -> b -> Magma i t b a -> b # foldl' :: (b -> a -> b) -> b -> Magma i t b a -> b # foldr1 :: (a -> a -> a) -> Magma i t b a -> a # foldl1 :: (a -> a -> a) -> Magma i t b a -> a # toList :: Magma i t b a -> [a] # null :: Magma i t b a -> Bool # length :: Magma i t b a -> Int # elem :: Eq a => a -> Magma i t b a -> Bool # maximum :: Ord a => Magma i t b a -> a # minimum :: Ord a => Magma i t b a -> a # sum :: Num a => Magma i t b a -> a # product :: Num a => Magma i t b a -> a #
Traversable (Magma i t b) # |
Methods traverse :: Applicative f => (a -> f b) -> Magma i t b a -> f (Magma i t b b) # sequenceA :: Applicative f => Magma i t b (f a) -> f (Magma i t b a) # mapM :: Monad m => (a -> m b) -> Magma i t b a -> m (Magma i t b b) # sequence :: Monad m => Magma i t b (m a) -> m (Magma i t b a) #
(Show i, Show a) => Show (Magma i t b a) # |
Methods showsPrec :: Int -> Magma i t b a -> ShowS # show :: Magma i t b a -> String # showList :: [Magma i t b a] -> ShowS #

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

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

# Molten

newtype Molten i a b t #

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

Constructors

Molten |
Fields runMolten :: Magma i t b a

Instances

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 #
IndexedFunctor (Molten i) # |
Methods ifmap :: (s -> t) -> Molten i a b s -> Molten i a b t #
Sellable (Indexed i) (Molten i) # |
Methods sell :: Indexed i a (Molten i a b b) #
Bizarre (Indexed i) (Molten i) # |
Methods bazaar :: Applicative f => Indexed i a (f b) -> Molten i a b t -> f t #
Functor (Molten i a b) # |
Methods fmap :: (a -> b) -> Molten i a b a -> Molten i a b b # (<$) :: a -> Molten i a b b -> Molten i a b a #
Applicative (Molten i a b) # |
Methods pure :: a -> Molten i a b a # (<*>) :: Molten i a b (a -> b) -> Molten i a b a -> Molten i a b b # (*>) :: Molten i a b a -> Molten i a b b -> Molten i a b b # (<*) :: Molten i a b a -> Molten i a b b -> Molten i a b a #
(~) * a b => Comonad (Molten i a b) # |
Methods extract :: Molten i a b a -> a # duplicate :: Molten i a b a -> Molten i a b (Molten i a b a) # extend :: (Molten i a b a -> b) -> Molten i a b a -> Molten i a b b #
Apply (Molten i a b) # |
Methods (<.>) :: Molten i a b (a -> b) -> Molten i a b a -> Molten i a b b # (.>) :: Molten i a b a -> Molten i a b b -> Molten i a b b # (<.) :: Molten i a b a -> Molten i a b b -> Molten i a b a #

# Mafic

data Mafic a b t #

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 # |
Methods ifmap :: (s -> t) -> Mafic a b s -> Mafic a b t #
Sellable (->) Mafic # |
Methods sell :: a -> Mafic a b b #
Bizarre (Indexed Int) Mafic # |
Methods bazaar :: Applicative f => Indexed Int a (f b) -> Mafic a b t -> f t #
Functor (Mafic a b) # |
Methods fmap :: (a -> b) -> Mafic a b a -> Mafic a b b # (<$) :: a -> Mafic a b b -> Mafic a b a #
Applicative (Mafic a b) # |
Methods pure :: a -> Mafic a b a # (<*>) :: Mafic a b (a -> b) -> Mafic a b a -> Mafic a b b # (*>) :: Mafic a b a -> Mafic a b b -> Mafic a b b # (<*) :: Mafic a b a -> Mafic a b b -> Mafic a b a #
Apply (Mafic a b) # |
Methods (<.>) :: Mafic a b (a -> b) -> Mafic a b a -> Mafic a b b # (.>) :: Mafic a b a -> Mafic a b b -> Mafic a b b # (<.) :: Mafic a b a -> Mafic a b b -> Mafic a b a #

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

Generate a `Magma` using from a prefix sum.

# TakingWhile

data TakingWhile p g a b t #

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) # |
Methods bazaar :: Applicative f => p a (f b) -> TakingWhile p g a b t -> f t #
IndexedFunctor (TakingWhile p f) # |
Methods ifmap :: (s -> t) -> TakingWhile p f a b s -> TakingWhile p f a b t #
Functor (TakingWhile p f a b) # |
Methods fmap :: (a -> b) -> TakingWhile p f a b a -> TakingWhile p f a b b # (<$) :: a -> TakingWhile p f a b b -> TakingWhile p f a b a #
Applicative (TakingWhile p f a b) # |
Methods pure :: a -> TakingWhile p f a b a # (<*>) :: TakingWhile p f a b (a -> b) -> TakingWhile p f a b a -> TakingWhile p f a b b # (*>) :: TakingWhile p f a b a -> TakingWhile p f a b b -> TakingWhile p f a b b # (<*) :: TakingWhile p f a b a -> TakingWhile p f a b b -> TakingWhile p f a b a #
Contravariant f => Contravariant (TakingWhile p f a b) # |
Methods contramap :: (a -> b) -> TakingWhile p f a b b -> TakingWhile p f a b a # (>$) :: b -> TakingWhile p f a b b -> TakingWhile p f a b a #
Apply (TakingWhile p f a b) # |
Methods (<.>) :: TakingWhile p f a b (a -> b) -> TakingWhile p f a b a -> TakingWhile p f a b b # (.>) :: TakingWhile p f a b a -> TakingWhile p f a b b -> TakingWhile p f a b b # (<.) :: TakingWhile p f a b a -> TakingWhile p f a b b -> TakingWhile p f a b a #

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

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