profunctor-optics-0.0.1: An optics library compatible with the typeclasses in 'profunctors'.

Safe HaskellNone
LanguageHaskell2010

Data.Profunctor.Optic.Index

Contents

Synopsis

Indexing

(%) :: (Additive - Semigroup) i => Representable p => IndexedOptic p i b1 b2 a1 a2 -> IndexedOptic p i c1 c2 b1 b2 -> IndexedOptic p i c1 c2 a1 a2 infixr 8 Source #

iinit :: Profunctor p => IndexedOptic p i s t a b -> IndexedOptic p (First i) s t a b Source #

ilast :: Profunctor p => IndexedOptic p i s t a b -> IndexedOptic p (Last i) s t a b Source #

reix :: Profunctor p => (i -> j) -> (j -> i) -> IndexedOptic p i s t a b -> IndexedOptic p j s t a b Source #

Map over the indices of an indexed optic.

See also reixed.

imap :: Profunctor p => (s -> a) -> (b -> t) -> IndexedOptic p i s t a b Source #

withIxrepn :: Representable p => IndexedOptic p i s t a b -> i -> s -> (i -> a -> Rep p b) -> Rep p t Source #

Coindexing

(#) :: (Additive - Semigroup) k => Corepresentable p => CoindexedOptic p k b1 b2 a1 a2 -> CoindexedOptic p k c1 c2 b1 b2 -> CoindexedOptic p k c1 c2 a1 a2 infixr 8 Source #

Compose two coindexed traversals, combining indices.

Its precedence is one lower than that of function composition, which allows . to be nested in #.

If you only need the final index then use ..

kinit :: Profunctor p => CoindexedOptic p k s t a b -> CoindexedOptic p (First k) s t a b Source #

klast :: Profunctor p => CoindexedOptic p k s t a b -> CoindexedOptic p (Last k) s t a b Source #

recx :: Profunctor p => (k -> l) -> (l -> k) -> CoindexedOptic p k s t a b -> CoindexedOptic p l s t a b Source #

Map over the indices of a coindexed optic.

See also recxed.

kmap :: Profunctor p => (s -> a) -> (b -> t) -> CoindexedOptic p k s t a b Source #

cxed :: Strong p => Iso (Cx p s s t) (Cx p k a b) (p s t) (p a b) Source #

kjoin :: Strong p => Cx p a a b -> p a b Source #

kreturn :: Profunctor p => p a b -> Cx p k a b Source #

type Cx' p a b = Cx p a a b Source #

kunit :: Strong p => Cx' p :-> p Source #

kpastro :: Profunctor p => Iso (Cx' p a b) (Cx' p c d) (Pastro p a b) (Pastro p c d) Source #

kfirst' :: Profunctor p => Cx' p a b -> Cx' p (a, c) (b, c) Source #

withCxrepn :: Corepresentable p => CoindexedOptic p k s t a b -> Corep p s -> k -> (Corep p a -> k -> b) -> t Source #

Index

data Index a b s Source #

An indexed store that characterizes a Lens

Index a b s ≡ forall f. Functor f => (a -> f b) -> f s,

See also withLensVl.

Constructors

Index a (b -> s) 
Instances
Profunctor (Index a) Source # 
Instance details

Defined in Data.Profunctor.Optic.Index

Methods

dimap :: (a0 -> b) -> (c -> d) -> Index a b c -> Index a a0 d #

lmap :: (a0 -> b) -> Index a b c -> Index a a0 c #

rmap :: (b -> c) -> Index a a0 b -> Index a a0 c #

(#.) :: Coercible c b => q b c -> Index a a0 b -> Index a a0 c #

(.#) :: Coercible b a0 => Index a b c -> q a0 b -> Index a a0 c #

Functor (Index a b) Source # 
Instance details

Defined in Data.Profunctor.Optic.Index

Methods

fmap :: (a0 -> b0) -> Index a b a0 -> Index a b b0 #

(<$) :: a0 -> Index a b b0 -> Index a b a0 #

a ~ b => Foldable (Index a b) Source # 
Instance details

Defined in Data.Profunctor.Optic.Index

Methods

fold :: Monoid m => Index a b m -> m #

foldMap :: Monoid m => (a0 -> m) -> Index a b a0 -> m #

foldr :: (a0 -> b0 -> b0) -> b0 -> Index a b a0 -> b0 #

foldr' :: (a0 -> b0 -> b0) -> b0 -> Index a b a0 -> b0 #

foldl :: (b0 -> a0 -> b0) -> b0 -> Index a b a0 -> b0 #

foldl' :: (b0 -> a0 -> b0) -> b0 -> Index a b a0 -> b0 #

foldr1 :: (a0 -> a0 -> a0) -> Index a b a0 -> a0 #

foldl1 :: (a0 -> a0 -> a0) -> Index a b a0 -> a0 #

toList :: Index a b a0 -> [a0] #

null :: Index a b a0 -> Bool #

length :: Index a b a0 -> Int #

elem :: Eq a0 => a0 -> Index a b a0 -> Bool #

maximum :: Ord a0 => Index a b a0 -> a0 #

minimum :: Ord a0 => Index a b a0 -> a0 #

sum :: Num a0 => Index a b a0 -> a0 #

product :: Num a0 => Index a b a0 -> a0 #

Sieve (LensRep a b) (Index a b) Source # 
Instance details

Defined in Data.Profunctor.Optic.Carrier

Methods

sieve :: LensRep a b a0 b0 -> a0 -> Index a b b0 #

Sieve (IsoRep a b) (Index a b) Source # 
Instance details

Defined in Data.Profunctor.Optic.Carrier

Methods

sieve :: IsoRep a b a0 b0 -> a0 -> Index a b b0 #

Generic (Index a b s) Source # 
Instance details

Defined in Data.Profunctor.Optic.Index

Associated Types

type Rep (Index a b s) :: Type -> Type #

Methods

from :: Index a b s -> Rep (Index a b s) x #

to :: Rep (Index a b s) x -> Index a b s #

type Rep (Index a b s) Source # 
Instance details

Defined in Data.Profunctor.Optic.Index

type Rep (Index a b s) = D1 (MetaData "Index" "Data.Profunctor.Optic.Index" "profunctor-optics-0.0.1-EeBm7Uc3lv1EUNgahi3W1m" False) (C1 (MetaCons "Index" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (b -> s))))

vals :: Index a b s -> b -> s Source #

info :: Index a b s -> a Source #

Coindex

newtype Coindex a b s Source #

An indexed continuation that characterizes a Grate

Coindex a b s ≡ forall f. Functor f => (f a -> b) -> f s,

See also withGrateVl.

Coindex can also be used to compose indexed maps, folds, or traversals directly.

For example, using the containers library:

 Coindex mapWithKey :: Coindex (a -> b) (Map k a -> Map k b) k
 Coindex foldMapWithKey :: Monoid m => Coindex (a -> m) (Map k a -> m) k
 Coindex traverseWithKey :: Applicative t => Coindex (a -> t b) (Map k a -> t (Map k b)) k

Constructors

Coindex 

Fields

Instances
Functor (Coindex a b) Source # 
Instance details

Defined in Data.Profunctor.Optic.Index

Methods

fmap :: (a0 -> b0) -> Coindex a b a0 -> Coindex a b b0 #

(<$) :: a0 -> Coindex a b b0 -> Coindex a b a0 #

a ~ b => Applicative (Coindex a b) Source # 
Instance details

Defined in Data.Profunctor.Optic.Index

Methods

pure :: a0 -> Coindex a b a0 #

(<*>) :: Coindex a b (a0 -> b0) -> Coindex a b a0 -> Coindex a b b0 #

liftA2 :: (a0 -> b0 -> c) -> Coindex a b a0 -> Coindex a b b0 -> Coindex a b c #

(*>) :: Coindex a b a0 -> Coindex a b b0 -> Coindex a b b0 #

(<*) :: Coindex a b a0 -> Coindex a b b0 -> Coindex a b a0 #

a ~ b => Apply (Coindex a b) Source # 
Instance details

Defined in Data.Profunctor.Optic.Index

Methods

(<.>) :: Coindex a b (a0 -> b0) -> Coindex a b a0 -> Coindex a b b0 #

(.>) :: Coindex a b a0 -> Coindex a b b0 -> Coindex a b b0 #

(<.) :: Coindex a b a0 -> Coindex a b b0 -> Coindex a b a0 #

liftF2 :: (a0 -> b0 -> c) -> Coindex a b a0 -> Coindex a b b0 -> Coindex a b c #

Cosieve (GrateRep a b) (Coindex a b) Source # 
Instance details

Defined in Data.Profunctor.Optic.Carrier

Methods

cosieve :: GrateRep a b a0 b0 -> Coindex a b a0 -> b0 #

Cosieve (IsoRep a b) (Coindex a b) Source # 
Instance details

Defined in Data.Profunctor.Optic.Carrier

Methods

cosieve :: IsoRep a b a0 b0 -> Coindex a b a0 -> b0 #

Generic (Coindex a b s) Source # 
Instance details

Defined in Data.Profunctor.Optic.Index

Associated Types

type Rep (Coindex a b s) :: Type -> Type #

Methods

from :: Coindex a b s -> Rep (Coindex a b s) x #

to :: Rep (Coindex a b s) x -> Coindex a b s #

type Rep (Coindex a b s) Source # 
Instance details

Defined in Data.Profunctor.Optic.Index

type Rep (Coindex a b s) = D1 (MetaData "Coindex" "Data.Profunctor.Optic.Index" "profunctor-optics-0.0.1-EeBm7Uc3lv1EUNgahi3W1m" True) (C1 (MetaCons "Coindex" PrefixI True) (S1 (MetaSel (Just "runCoindex") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 ((s -> a) -> b))))

trivial :: Coindex a b a -> b Source #

noindex :: Monoid s => (a -> b) -> Coindex a b s Source #

Lift a regular function into a coindexed function.

For example, to traverse two layers, keeping only the first index:

 Coindex mapWithKey .#. noindex map
   :: Monoid k =>
      Coindex (a -> b) (Map k (Map j a) -> Map k (Map j b)) k

coindex :: Functor f => s -> (a -> b) -> Coindex (f a) (f b) s Source #

(.#.) :: Semigroup s => Coindex b c s -> Coindex a b s -> Coindex a c s infixr 9 Source #

Compose two coindexes.

When s is a Monoid, Coindex can be used to compose indexed traversals, folds, etc.

For example, to keep track of only the first index seen, use Data.Monoid.First:

 fmap (First . pure) :: Coindex a b c -> Coindex a b (First c)

or keep track of all indices using a list:

 fmap (:[]) :: Coindex a b c -> Coindex a b [c]

Coindex

newtype Conjoin j a b Source #

Constructors

Conjoin 

Fields

Instances
Arrow (Conjoin j) Source # 
Instance details

Defined in Data.Profunctor.Optic.Index

Methods

arr :: (b -> c) -> Conjoin j b c #

first :: Conjoin j b c -> Conjoin j (b, d) (c, d) #

second :: Conjoin j b c -> Conjoin j (d, b) (d, c) #

(***) :: Conjoin j b c -> Conjoin j b' c' -> Conjoin j (b, b') (c, c') #

(&&&) :: Conjoin j b c -> Conjoin j b c' -> Conjoin j b (c, c') #

ArrowChoice (Conjoin j) Source # 
Instance details

Defined in Data.Profunctor.Optic.Index

Methods

left :: Conjoin j b c -> Conjoin j (Either b d) (Either c d) #

right :: Conjoin j b c -> Conjoin j (Either d b) (Either d c) #

(+++) :: Conjoin j b c -> Conjoin j b' c' -> Conjoin j (Either b b') (Either c c') #

(|||) :: Conjoin j b d -> Conjoin j c d -> Conjoin j (Either b c) d #

ArrowApply (Conjoin j) Source # 
Instance details

Defined in Data.Profunctor.Optic.Index

Methods

app :: Conjoin j (Conjoin j b c, b) c #

ArrowLoop (Conjoin j) Source # 
Instance details

Defined in Data.Profunctor.Optic.Index

Methods

loop :: Conjoin j (b, d) (c, d) -> Conjoin j b c #

Representable (Conjoin j) Source # 
Instance details

Defined in Data.Profunctor.Optic.Index

Associated Types

type Rep (Conjoin j) :: Type -> Type #

Methods

tabulate :: (d -> Rep (Conjoin j) c) -> Conjoin j d c #

Corepresentable (Conjoin j) Source # 
Instance details

Defined in Data.Profunctor.Optic.Index

Associated Types

type Corep (Conjoin j) :: Type -> Type #

Methods

cotabulate :: (Corep (Conjoin j) d -> c) -> Conjoin j d c #

Choice (Conjoin j) Source # 
Instance details

Defined in Data.Profunctor.Optic.Index

Methods

left' :: Conjoin j a b -> Conjoin j (Either a c) (Either b c) #

right' :: Conjoin j a b -> Conjoin j (Either c a) (Either c b) #

Closed (Conjoin j) Source # 
Instance details

Defined in Data.Profunctor.Optic.Index

Methods

closed :: Conjoin j a b -> Conjoin j (x -> a) (x -> b) #

Strong (Conjoin j) Source # 
Instance details

Defined in Data.Profunctor.Optic.Index

Methods

first' :: Conjoin j a b -> Conjoin j (a, c) (b, c) #

second' :: Conjoin j a b -> Conjoin j (c, a) (c, b) #

Costrong (Conjoin j) Source # 
Instance details

Defined in Data.Profunctor.Optic.Index

Methods

unfirst :: Conjoin j (a, d) (b, d) -> Conjoin j a b #

unsecond :: Conjoin j (d, a) (d, b) -> Conjoin j a b #

Profunctor (Conjoin j) Source # 
Instance details

Defined in Data.Profunctor.Optic.Index

Methods

dimap :: (a -> b) -> (c -> d) -> Conjoin j b c -> Conjoin j a d #

lmap :: (a -> b) -> Conjoin j b c -> Conjoin j a c #

rmap :: (b -> c) -> Conjoin j a b -> Conjoin j a c #

(#.) :: Coercible c b => q b c -> Conjoin j a b -> Conjoin j a c #

(.#) :: Coercible b a => Conjoin j b c -> q a b -> Conjoin j a c #

Category (Conjoin j :: Type -> Type -> Type) Source # 
Instance details

Defined in Data.Profunctor.Optic.Index

Methods

id :: Conjoin j a a #

(.) :: Conjoin j b c -> Conjoin j a b -> Conjoin j a c #

Cosieve (Conjoin j) ((,) j) Source # 
Instance details

Defined in Data.Profunctor.Optic.Index

Methods

cosieve :: Conjoin j a b -> (j, a) -> b #

Sieve (Conjoin j) ((->) j :: Type -> Type) Source # 
Instance details

Defined in Data.Profunctor.Optic.Index

Methods

sieve :: Conjoin j a b -> a -> j -> b #

Monad (Conjoin j a) Source # 
Instance details

Defined in Data.Profunctor.Optic.Index

Methods

(>>=) :: Conjoin j a a0 -> (a0 -> Conjoin j a b) -> Conjoin j a b #

(>>) :: Conjoin j a a0 -> Conjoin j a b -> Conjoin j a b #

return :: a0 -> Conjoin j a a0 #

fail :: String -> Conjoin j a a0 #

Functor (Conjoin j a) Source # 
Instance details

Defined in Data.Profunctor.Optic.Index

Methods

fmap :: (a0 -> b) -> Conjoin j a a0 -> Conjoin j a b #

(<$) :: a0 -> Conjoin j a b -> Conjoin j a a0 #

MonadFix (Conjoin j a) Source # 
Instance details

Defined in Data.Profunctor.Optic.Index

Methods

mfix :: (a0 -> Conjoin j a a0) -> Conjoin j a a0 #

Applicative (Conjoin j a) Source # 
Instance details

Defined in Data.Profunctor.Optic.Index

Methods

pure :: a0 -> Conjoin j a a0 #

(<*>) :: Conjoin j a (a0 -> b) -> Conjoin j a a0 -> Conjoin j a b #

liftA2 :: (a0 -> b -> c) -> Conjoin j a a0 -> Conjoin j a b -> Conjoin j a c #

(*>) :: Conjoin j a a0 -> Conjoin j a b -> Conjoin j a b #

(<*) :: Conjoin j a a0 -> Conjoin j a b -> Conjoin j a a0 #

Apply (Conjoin j a) Source # 
Instance details

Defined in Data.Profunctor.Optic.Index

Methods

(<.>) :: Conjoin j a (a0 -> b) -> Conjoin j a a0 -> Conjoin j a b #

(.>) :: Conjoin j a a0 -> Conjoin j a b -> Conjoin j a b #

(<.) :: Conjoin j a a0 -> Conjoin j a b -> Conjoin j a a0 #

liftF2 :: (a0 -> b -> c) -> Conjoin j a a0 -> Conjoin j a b -> Conjoin j a c #

type Rep (Conjoin j) Source # 
Instance details

Defined in Data.Profunctor.Optic.Index

type Rep (Conjoin j) = ((->) j :: Type -> Type)
type Corep (Conjoin j) Source # 
Instance details

Defined in Data.Profunctor.Optic.Index

type Corep (Conjoin j) = (,) j