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

Safe HaskellSafe
LanguageHaskell2010

Data.Profunctor.Optic.Setter

Contents

Synopsis

Setter

type Setter s t a b = forall p. (Closed p, Choice p, Representable p, Applicative (Rep p), Distributive (Rep p)) => Optic p s t a b Source #

A Setter modifies part of a structure.

\( \mathsf{Setter}\;S\;A = \exists F : \mathsf{Functor}, S \equiv F\,A \)

type Setter' s a = Setter s s a a Source #

setter :: ((a -> b) -> s -> t) -> Setter s t a b Source #

Obtain a Setter from a SEC.

To demote an optic to a semantic edit combinator, use the section (l ..~) or over l.

>>> [("The",0),("quick",1),("brown",1),("fox",2)] & setter fmap . t21 ..~ Prelude.length
[(3,0),(5,1),(5,1),(3,2)]

Caution: In order for the generated optic to be well-defined, you must ensure that the input function satisfies the following properties:

  • abst id ≡ id
  • abst f . abst g ≡ abst (f . g)

More generally, a profunctor optic must be monoidal as a natural transformation:

See Property.

ixsetter :: ((i -> a -> b) -> s -> t) -> Ixsetter i s t a b Source #

Build an Ixsetter from an indexed function.

ixsetter . ixoverid
ixover . ixsetterid

Caution: In order for the generated optic to be well-defined, you must ensure that the input satisfies the following properties:

  • iabst (const id) ≡ id
  • fmap (iabst $ const f) . (iabst $ const g) ≡ iabst (const $ f . g)

See Property.

closing :: (((s -> a) -> b) -> t) -> Setter s t a b Source #

Every valid Grate is a Setter.

Resetter

type Resetter s t a b = forall p. (Closed p, Cochoice p, Corepresentable p, Apply (Corep p), Traversable (Corep p)) => Optic p s t a b Source #

type Resetter' s a = Resetter s s a a Source #

resetter :: ((a -> t) -> s -> t) -> Resetter s t a t Source #

Obtain a Resetter from a SEC.

Caution: In order for the generated optic to be well-defined, you must ensure that the input function satisfies the following properties:

  • abst id ≡ id
  • abst f . abst g ≡ abst (f . g)

cxsetter :: ((k -> a -> t) -> s -> t) -> Cxsetter k s t a t Source #

TODO: Document

Caution: In order for the generated optic to be well-defined, you must ensure that the input satisfies the following properties:

  • kabst (const id) ≡ id
  • fmap (kabst $ const f) . (kabst $ const g) ≡ kabst (const $ f . g)

See Property.

Optics

cod :: Profunctor p => Setter (p r a) (p r b) a b Source #

Map covariantly over the output of a Profunctor.

The most common profunctor to use this with is (->).

(dom ..~ f) g x ≡ f (g x)
cod @(->) ≡ withGrate closed closing
>>> (cod ..~ show) length [1,2,3]
"3"

dom :: Profunctor p => Setter (p b r) (p a r) a b Source #

Map contravariantly over the input of a Profunctor.

The most common profunctor to use this with is (->).

(dom ..~ f) g x ≡ g (f x)
>>> (dom ..~ show) length [1,2,3]
7

bound :: Monad m => Setter (m a) (m b) a (m b) Source #

Setter for monadically transforming a monadic value.

fmapped :: Functor f => Setter (f a) (f b) a b Source #

Setter on each value of a functor.

contramapped :: Contravariant f => Setter (f b) (f a) a b Source #

This Setter can be used to map over all of the inputs to a Contravariant.

contramapover contramapped
>>> getPredicate (over contramapped (*2) (Predicate even)) 5
True
>>> getOp (over contramapped (*5) (Op show)) 100
"500"

setmapped :: Ord b => Setter (Set a) (Set b) a b Source #

>>> over setmapped (+1) (Set.fromList [1,2,3,4])
fromList [2,3,4,5]

isetmapped :: Setter' IntSet Int Source #

>>> over isetmapped (+1) (IntSet.fromList [1,2,3,4])
fromList [2,3,4,5]

foldmapped :: Foldable f => Monoid m => Setter (f a) m a m Source #

TODO: Document

liftedA :: Applicative f => Setter (f a) (f b) a b Source #

This setter can be used to modify all of the values in an Applicative.

liftAsetter liftedA
>>> setter liftedA Identity [1,2,3]
[Identity 1,Identity 2,Identity 3]
>>> set liftedA 2 (Just 1)
Just 2

liftedM :: Monad m => Setter (m a) (m b) a b Source #

TODO: Document

locally :: Setter (ReaderT r2 m a) (ReaderT r1 m a) r1 r2 Source #

Modify the local environment of a Reader.

Use to lift reader actions into a larger environment:

>>> runReader ( ask & locally ..~ fst ) (1,2)
1

zipped :: Setter (u -> v -> a) (u -> v -> b) a b Source #

TODO: Document

cond :: (a -> Bool) -> Setter' a a Source #

Apply a function only when the given condition holds.

See also predicated & filtered.

modded :: (a -> Bool) -> Setter' (a -> b) b Source #

TODO: Document

reviewed :: Setter (b -> t) (((s -> a) -> b) -> t) s a Source #

TODO: Document

composed :: Setter (s -> a) ((a -> b) -> s -> t) b t Source #

TODO: Document

exmapped :: Exception e1 => Exception e2 => Setter s s e1 e2 Source #

Map one exception into another as proposed in the paper "A semantics for imprecise exceptions".

>>> handles (only Overflow) (\_ -> return "caught") $ assert False (return "uncaught") & (exmapped ..~ \ (AssertionFailed _) -> Overflow)
"caught"
exmapped :: Exception e => Setter s s SomeException e

Primitive operators

over :: ASetter s t a b -> (a -> b) -> s -> t Source #

Extract a SEC from a Setter.

Used to modify the target of a Lens or all the targets of a Setter or Traversal.

over o idid 
over o f . over o g ≡ over o (f . g)
setter . overid
over . setterid
>>> over fmapped (+1) (Just 1)
Just 2
>>> over fmapped (*10) [1,2,3]
[10,20,30]
>>> over t21 (+1) (1,2)
(2,2)
>>> over t21 show (10,20)
("10",20)
over :: Setter s t a b -> (a -> r) -> s -> r
over :: Monoid r => Fold s t a b -> (a -> r) -> s -> r

ixover :: Monoid i => AIxsetter i s t a b -> (i -> a -> b) -> s -> t Source #

>>> ixover (ixat 1) (+) [1,2,3 :: Int]
[1,3,3]
>>> ixover (ixat 5) (+) [1,2,3 :: Int]
[1,2,3]

under :: AResetter s t a b -> (a -> b) -> s -> t Source #

Extract a SEC from a Resetter.

under o idid 
under o f . under o g ≡ under o (f . g)
resetter . underid
under . resetterid

Note that under (more properly co-over) is distinct from reover:

>>> :t under $ wrapped @(Identity Int)
under $ wrapped @(Identity Int)
  :: (Int -> Int) -> Identity Int -> Identity Int
>>> :t over $ wrapped @(Identity Int)
over $ wrapped @(Identity Int)
  :: (Int -> Int) -> Identity Int -> Identity Int
>>> :t over . re $ wrapped @(Identity Int)
over . re $ wrapped @(Identity Int)
  :: (Identity Int -> Identity Int) -> Int -> Int
>>> :t reover $ wrapped @(Identity Int)
reover $ wrapped @(Identity Int)
  :: (Identity Int -> Identity Int) -> Int -> Int

Compare to the lens-family version.

cxover :: Monoid k => ACxsetter k s t a b -> (k -> a -> b) -> s -> t Source #

>>> cxover (catchOn 42) (\k msg -> show k ++ ": " ++ msg) $ Just "foo"
Just "0: foo"
>>> cxover (catchOn 42) (\k msg -> show k ++ ": " ++ msg) Nothing
Nothing
>>> cxover (catchOn 0) (\k msg -> show k ++ ": " ++ msg) Nothing
Just "caught"

through :: Optic (->) s t a b -> (a -> b) -> s -> t Source #

The join of under and over.

Operators

assignA :: Category p => Strong p => ASetter s t a b -> Optic p s t s b Source #

Run a profunctor arrow command and set the optic targets to the result.

Similar to assign, except that the type of the object being modified can change.

>>> getVal1 = Right 3
>>> getVal2 = Right False
>>> action = assignA t21 (Kleisli (const getVal1)) >>> assignA t22 (Kleisli (const getVal2))
>>> runKleisli action ((), ())
Right (3,False)
assignA :: Category p => Iso s t a b       -> Lenslike p s t s b
assignA :: Category p => Lens s t a b      -> Lenslike p s t s b
assignA :: Category p => Grate s t a b     -> Lenslike p s t s b
assignA :: Category p => Setter s t a b    -> Lenslike p s t s b
assignA :: Category p => Traversal s t a b -> Lenslike p s t s b

set :: ASetter s t a b -> b -> s -> t Source #

Set all referenced fields to the given value.

 set l y (set l x a) ≡ set l y a

ixset :: Monoid i => AIxsetter i s t a b -> (i -> b) -> s -> t Source #

Set with index. Equivalent to ixover with the current value ignored.

When you do not need access to the index, then set is more liberal in what it can accept.

set o ≡ ixset o . const
>>> ixset (ixat 2) (2-) [1,2,3 :: Int]
[1,2,0]
>>> ixset (ixat 5) (const 0) [1,2,3 :: Int]
[1,2,3]

reset :: AResetter s t a b -> b -> s -> t Source #

Set all referenced fields to the given value.

resetset . re

cxset :: Monoid k => ACxsetter k s t a b -> (k -> b) -> s -> t Source #

Dual set with index. Equivalent to cxover with the current value ignored.

>>> cxset (catchOn 42) show $ Just "foo"
Just "0"
>>> cxset (catchOn 42) show Nothing
Nothing
>>> cxset (catchOn 0) show Nothing
Just "caught"

(.~) :: ASetter s t a b -> b -> s -> t infixr 4 Source #

TODO: Document

(..~) :: ASetter s t a b -> (a -> b) -> s -> t infixr 4 Source #

TODO: Document

>>> Nothing & just ..~ (+1)
Nothing

(/~) :: AResetter s t a b -> b -> s -> t infixr 4 Source #

An infix variant of reset. Dual to .~.

(//~) :: AResetter s t a b -> (a -> b) -> s -> t infixr 4 Source #

An infix variant of under. Dual to ..~.

(?~) :: ASetter s t a (Maybe b) -> b -> s -> t infixr 4 Source #

Set the target of a settable optic to Just a value.

l ?~ t ≡ set l (Just t)
>>> Nothing & id ?~ 1
Just 1

?~ can be used type-changily:

>>> ('a', ('b', 'c')) & t22 . both ?~ 'x'
('a',(Just 'x',Just 'x'))
(?~) :: Iso s t a (Maybe b)       -> b -> s -> t
(?~) :: Lens s t a (Maybe b)      -> b -> s -> t
(?~) :: Grate s t a (Maybe b)     -> b -> s -> t
(?~) :: Setter s t a (Maybe b)    -> b -> s -> t
(?~) :: Traversal s t a (Maybe b) -> b -> s -> t

(<>~) :: Semigroup a => ASetter s t a a -> a -> s -> t infixr 4 Source #

Modify the target by adding another value.

>>> both <>~ False $ (False,True)
(False,True)
>>> both <>~ "!!!" $ ("hello","world")
("hello!!!","world!!!")
(<>~) :: Semigroup a => Iso s t a a       -> a -> s -> t
(<>~) :: Semigroup a => Lens s t a a      -> a -> s -> t
(<>~) :: Semigroup a => Grate s t a a     -> a -> s -> t
(<>~) :: Semigroup a => Setter s t a a    -> a -> s -> t
(<>~) :: Semigroup a => Traversal s t a a -> a -> s -> t

(><~) :: Semiring a => ASetter s t a a -> a -> s -> t infixr 4 Source #

Modify the target by multiplying by another value.

>>> both ><~ False $ (False,True)
(False,False)
(><~) :: Semiring a => Iso s t a a       -> a -> s -> t
(><~) :: Semiring a => Lens s t a a      -> a -> s -> t
(><~) :: Semiring a => Grate s t a a     -> a -> s -> t
(><~) :: Semiring a => Setter s t a a    -> a -> s -> t
(><~) :: Semiring a => Traversal s t a a -> a -> s -> t

Indexed Operators

(%~) :: Monoid i => AIxsetter i s t a b -> (i -> b) -> s -> t infixr 4 Source #

An infix variant of ixset. Dual to #~.

(%%~) :: Monoid i => AIxsetter i s t a b -> (i -> a -> b) -> s -> t infixr 4 Source #

An infix variant of ixover. Dual to ##~.

(#~) :: Monoid k => ACxsetter k s t a b -> (k -> b) -> s -> t infixr 4 Source #

An infix variant of cxset. Dual to %~.

(##~) :: Monoid k => ACxsetter k s t a b -> (k -> a -> b) -> s -> t infixr 4 Source #

An infix variant of cxover. Dual to %%~.

>>> Just "foo" & catchOn 0 ##~ (\k msg -> show k ++ ": " ++ msg)
Just "0: foo"
>>> Nothing & catchOn 0 ##~ (\k msg -> show k ++ ": " ++ msg)
Just "caught"

MonadState

assigns :: MonadState s m => ASetter s s a b -> b -> m () Source #

Replace the target(s) of a settable in a monadic state.

assigns :: MonadState s m => Iso' s a       -> a -> m ()
assigns :: MonadState s m => Lens' s a      -> a -> m ()
assigns :: MonadState s m => Grate' s a     -> a -> m ()
assigns :: MonadState s m => Prism' s a     -> a -> m ()
assigns :: MonadState s m => Setter' s a    -> a -> m ()
assigns :: MonadState s m => Traversal' s a -> a -> m ()

modifies :: MonadState s m => ASetter s s a b -> (a -> b) -> m () Source #

Map over the target(s) of a Setter in a monadic state.

modifies :: MonadState s m => Iso' s a       -> (a -> a) -> m ()
modifies :: MonadState s m => Lens' s a      -> (a -> a) -> m ()
modifies :: MonadState s m => Grate' s a     -> (a -> a) -> m ()
modifies :: MonadState s m => Prism' s a     -> (a -> a) -> m ()
modifies :: MonadState s m => Setter' s a    -> (a -> a) -> m ()
modifies :: MonadState s m => Traversal' s a -> (a -> a) -> m ()

(.=) :: MonadState s m => ASetter s s a b -> b -> m () infix 4 Source #

Replace the target(s) of a settable in a monadic state.

This is an infix version of assigns.

>>> execState (do t21 .= 1; t22 .= 2) (3,4)
(1,2)
>>> execState (both .= 3) (1,2)
(3,3)
(.=) :: MonadState s m => Iso' s a       -> a -> m ()
(.=) :: MonadState s m => Lens' s a      -> a -> m ()
(.=) :: MonadState s m => Grate' s a    -> a -> m ()
(.=) :: MonadState s m => Prism' s a    -> a -> m ()
(.=) :: MonadState s m => Setter' s a    -> a -> m ()
(.=) :: MonadState s m => Traversal' s a -> a -> m ()

(..=) :: MonadState s m => ASetter s s a b -> (a -> b) -> m () infix 4 Source #

Map over the target(s) of a Setter in a monadic state.

This is an infix version of modifies.

>>> execState (do just ..= (+1) ) Nothing
Nothing
>>> execState (do t21 ..= (+1) ;t22 ..= (+2)) (1,2)
(2,4)
>>> execState (do both ..= (+1)) (1,2)
(2,3)
(..=) :: MonadState s m => Iso' s a       -> (a -> a) -> m ()
(..=) :: MonadState s m => Lens' s a      -> (a -> a) -> m ()
(..=) :: MonadState s m => Grate' s a     -> (a -> a) -> m ()
(..=) :: MonadState s m => Prism' s a     -> (a -> a) -> m ()
(..=) :: MonadState s m => Setter' s a    -> (a -> a) -> m ()
(..=) :: MonadState s m => Traversal' s a -> (a -> a) -> m ()

(%=) :: MonadState s m => Monoid i => AIxsetter i s s a b -> (i -> b) -> m () infix 4 Source #

TODO: Document

(%%=) :: MonadState s m => Monoid i => AIxsetter i s s a b -> (i -> a -> b) -> m () infix 4 Source #

TODO: Document

(//=) :: MonadState s m => AResetter s s a b -> (a -> b) -> m () infix 4 Source #

TODO: Document

(#=) :: MonadState s m => Monoid k => ACxsetter k s s a b -> (k -> b) -> m () infix 4 Source #

TODO: Document

(##=) :: MonadState s m => Monoid k => ACxsetter k s s a b -> (k -> a -> b) -> m () infix 4 Source #

TODO: Document

(?=) :: MonadState s m => ASetter s s a (Maybe b) -> b -> m () infix 4 Source #

Replace the target(s) of a settable optic with Just a new value.

>>> execState (do t21 ?= 1; t22 ?= 2) (Just 1, Nothing)
(Just 1,Just 2)
(?=) :: MonadState s m => Iso' s (Maybe a)       -> a -> m ()
(?=) :: MonadState s m => Lens' s (Maybe a)      -> a -> m ()
(?=) :: MonadState s m => Grate' s (Maybe a)     -> a -> m ()
(?=) :: MonadState s m => Prism' s (Maybe a)     -> a -> m ()
(?=) :: MonadState s m => Setter' s (Maybe a)    -> a -> m ()
(?=) :: MonadState s m => Traversal' s (Maybe a) -> a -> m ()

(<>=) :: MonadState s m => Semigroup a => ASetter' s a -> a -> m () infix 4 Source #

Modify the target(s) of a settable optic by adding a value.

>>> execState (both <>= False) (False,True)
(False,True)
>>> execState (both <>= "!!!") ("hello","world")
("hello!!!","world!!!")
(<>=) :: MonadState s m => Semigroup a => Iso' s a -> a -> m ()
(<>=) :: MonadState s m => Semigroup a => Lens' s a -> a -> m ()
(<>=) :: MonadState s m => Semigroup a => Grate' s a -> a -> m ()
(<>=) :: MonadState s m => Semigroup a => Prism' s a -> a -> m ()
(<>=) :: MonadState s m => Semigroup a => Setter' s a -> a -> m ()
(<>=) :: MonadState s m => Semigroup a => Traversal' s a -> a -> m ()

(><=) :: MonadState s m => Semiring a => ASetter' s a -> a -> m () infix 4 Source #

Modify the target(s) of a settable optic by mulitiplying by a value.

>>> execState (both ><= False) (False,True)
(False,False)
(><=) :: MonadState s m => Semiring a => Iso' s a -> a -> m ()
(><=) :: MonadState s m => Semiring a => Lens' s a -> a -> m ()
(><=) :: MonadState s m => Semiring a => Grate' s a -> a -> m ()
(><=) :: MonadState s m => Semiring a => Prism' s a -> a -> m ()
(><=) :: MonadState s m => Semiring a => Setter' s a -> a -> m ()
(><=) :: MonadState s m => Semiring a => Traversal' s a -> a -> m ()

zoom :: Functor m => Optic' (Star (Compose m ((,) c))) ta a -> StateT a m c -> StateT ta m c Source #

Carriers

type ASetter s t a b = ARepn Identity s t a b Source #

type ASetter' s a = ASetter s s a a Source #

newtype Star (f :: Type -> Type) d c #

Lift a Functor into a Profunctor (forwards).

Constructors

Star 

Fields

Instances
Functor f => Representable (Star f) 
Instance details

Defined in Data.Profunctor.Rep

Associated Types

type Rep (Star f) :: Type -> Type #

Methods

tabulate :: (d -> Rep (Star f) c) -> Star f d c #

Applicative f => Choice (Star f) 
Instance details

Defined in Data.Profunctor.Choice

Methods

left' :: Star f a b -> Star f (Either a c) (Either b c) #

right' :: Star f a b -> Star f (Either c a) (Either c b) #

Traversable f => Cochoice (Star f) 
Instance details

Defined in Data.Profunctor.Choice

Methods

unleft :: Star f (Either a d) (Either b d) -> Star f a b #

unright :: Star f (Either d a) (Either d b) -> Star f a b #

Distributive f => Closed (Star f) 
Instance details

Defined in Data.Profunctor.Closed

Methods

closed :: Star f a b -> Star f (x -> a) (x -> b) #

Functor m => Strong (Star m) 
Instance details

Defined in Data.Profunctor.Strong

Methods

first' :: Star m a b -> Star m (a, c) (b, c) #

second' :: Star m a b -> Star m (c, a) (c, b) #

Functor f => Profunctor (Star f) 
Instance details

Defined in Data.Profunctor.Types

Methods

dimap :: (a -> b) -> (c -> d) -> Star f b c -> Star f a d #

lmap :: (a -> b) -> Star f b c -> Star f a c #

rmap :: (b -> c) -> Star f a b -> Star f a c #

(#.) :: Coercible c b => q b c -> Star f a b -> Star f a c #

(.#) :: Coercible b a => Star f b c -> q a b -> Star f a c #

Functor f => Sieve (Star f) f 
Instance details

Defined in Data.Profunctor.Sieve

Methods

sieve :: Star f a b -> a -> f b #

Monad f => Category (Star f :: Type -> Type -> Type) 
Instance details

Defined in Data.Profunctor.Types

Methods

id :: Star f a a #

(.) :: Star f b c -> Star f a b -> Star f a c #

Monad f => Monad (Star f a) 
Instance details

Defined in Data.Profunctor.Types

Methods

(>>=) :: Star f a a0 -> (a0 -> Star f a b) -> Star f a b #

(>>) :: Star f a a0 -> Star f a b -> Star f a b #

return :: a0 -> Star f a a0 #

fail :: String -> Star f a a0 #

Functor f => Functor (Star f a) 
Instance details

Defined in Data.Profunctor.Types

Methods

fmap :: (a0 -> b) -> Star f a a0 -> Star f a b #

(<$) :: a0 -> Star f a b -> Star f a a0 #

Applicative f => Applicative (Star f a) 
Instance details

Defined in Data.Profunctor.Types

Methods

pure :: a0 -> Star f a a0 #

(<*>) :: Star f a (a0 -> b) -> Star f a a0 -> Star f a b #

liftA2 :: (a0 -> b -> c) -> Star f a a0 -> Star f a b -> Star f a c #

(*>) :: Star f a a0 -> Star f a b -> Star f a b #

(<*) :: Star f a a0 -> Star f a b -> Star f a a0 #

Contravariant f => Contravariant (Star f a) Source # 
Instance details

Defined in Data.Profunctor.Optic.Type

Methods

contramap :: (a0 -> b) -> Star f a b -> Star f a a0 #

(>$) :: b -> Star f a b -> Star f a a0 #

Alternative f => Alternative (Star f a) 
Instance details

Defined in Data.Profunctor.Types

Methods

empty :: Star f a a0 #

(<|>) :: Star f a a0 -> Star f a a0 -> Star f a a0 #

some :: Star f a a0 -> Star f a [a0] #

many :: Star f a a0 -> Star f a [a0] #

MonadPlus f => MonadPlus (Star f a) 
Instance details

Defined in Data.Profunctor.Types

Methods

mzero :: Star f a a0 #

mplus :: Star f a a0 -> Star f a a0 -> Star f a a0 #

Distributive f => Distributive (Star f a) 
Instance details

Defined in Data.Profunctor.Types

Methods

distribute :: Functor f0 => f0 (Star f a a0) -> Star f a (f0 a0) #

collect :: Functor f0 => (a0 -> Star f a b) -> f0 a0 -> Star f a (f0 b) #

distributeM :: Monad m => m (Star f a a0) -> Star f a (m a0) #

collectM :: Monad m => (a0 -> Star f a b) -> m a0 -> Star f a (m b) #

Apply f => Apply (Star f a) Source # 
Instance details

Defined in Data.Profunctor.Optic.Type

Methods

(<.>) :: Star f a (a0 -> b) -> Star f a a0 -> Star f a b #

(.>) :: Star f a a0 -> Star f a b -> Star f a b #

(<.) :: Star f a a0 -> Star f a b -> Star f a a0 #

liftF2 :: (a0 -> b -> c) -> Star f a a0 -> Star f a b -> Star f a c #

type Rep (Star f) 
Instance details

Defined in Data.Profunctor.Rep

type Rep (Star f) = f

type AResetter s t a b = ACorepn Identity s t a b Source #

type AResetter' s a = AResetter s s a a Source #

newtype Costar (f :: Type -> Type) d c #

Lift a Functor into a Profunctor (backwards).

Constructors

Costar 

Fields

Instances
Contravariant f => Bifunctor (Costar f) Source # 
Instance details

Defined in Data.Profunctor.Optic.Type

Methods

bimap :: (a -> b) -> (c -> d) -> Costar f a c -> Costar f b d #

first :: (a -> b) -> Costar f a c -> Costar f b c #

second :: (b -> c) -> Costar f a b -> Costar f a c #

Functor f => Corepresentable (Costar f) 
Instance details

Defined in Data.Profunctor.Rep

Associated Types

type Corep (Costar f) :: Type -> Type #

Methods

cotabulate :: (Corep (Costar f) d -> c) -> Costar f d c #

Traversable w => Choice (Costar w) 
Instance details

Defined in Data.Profunctor.Choice

Methods

left' :: Costar w a b -> Costar w (Either a c) (Either b c) #

right' :: Costar w a b -> Costar w (Either c a) (Either c b) #

Applicative f => Cochoice (Costar f) 
Instance details

Defined in Data.Profunctor.Choice

Methods

unleft :: Costar f (Either a d) (Either b d) -> Costar f a b #

unright :: Costar f (Either d a) (Either d b) -> Costar f a b #

Functor f => Closed (Costar f) 
Instance details

Defined in Data.Profunctor.Closed

Methods

closed :: Costar f a b -> Costar f (x -> a) (x -> b) #

Comonad f => Strong (Costar f) Source # 
Instance details

Defined in Data.Profunctor.Optic.Type

Methods

first' :: Costar f a b -> Costar f (a, c) (b, c) #

second' :: Costar f a b -> Costar f (c, a) (c, b) #

Functor f => Costrong (Costar f) 
Instance details

Defined in Data.Profunctor.Strong

Methods

unfirst :: Costar f (a, d) (b, d) -> Costar f a b #

unsecond :: Costar f (d, a) (d, b) -> Costar f a b #

Functor f => Profunctor (Costar f) 
Instance details

Defined in Data.Profunctor.Types

Methods

dimap :: (a -> b) -> (c -> d) -> Costar f b c -> Costar f a d #

lmap :: (a -> b) -> Costar f b c -> Costar f a c #

rmap :: (b -> c) -> Costar f a b -> Costar f a c #

(#.) :: Coercible c b => q b c -> Costar f a b -> Costar f a c #

(.#) :: Coercible b a => Costar f b c -> q a b -> Costar f a c #

Functor f => Cosieve (Costar f) f 
Instance details

Defined in Data.Profunctor.Sieve

Methods

cosieve :: Costar f a b -> f a -> b #

Monad (Costar f a) 
Instance details

Defined in Data.Profunctor.Types

Methods

(>>=) :: Costar f a a0 -> (a0 -> Costar f a b) -> Costar f a b #

(>>) :: Costar f a a0 -> Costar f a b -> Costar f a b #

return :: a0 -> Costar f a a0 #

fail :: String -> Costar f a a0 #

Functor (Costar f a) 
Instance details

Defined in Data.Profunctor.Types

Methods

fmap :: (a0 -> b) -> Costar f a a0 -> Costar f a b #

(<$) :: a0 -> Costar f a b -> Costar f a a0 #

Applicative (Costar f a) 
Instance details

Defined in Data.Profunctor.Types

Methods

pure :: a0 -> Costar f a a0 #

(<*>) :: Costar f a (a0 -> b) -> Costar f a a0 -> Costar f a b #

liftA2 :: (a0 -> b -> c) -> Costar f a a0 -> Costar f a b -> Costar f a c #

(*>) :: Costar f a a0 -> Costar f a b -> Costar f a b #

(<*) :: Costar f a a0 -> Costar f a b -> Costar f a a0 #

Distributive (Costar f d) 
Instance details

Defined in Data.Profunctor.Types

Methods

distribute :: Functor f0 => f0 (Costar f d a) -> Costar f d (f0 a) #

collect :: Functor f0 => (a -> Costar f d b) -> f0 a -> Costar f d (f0 b) #

distributeM :: Monad m => m (Costar f d a) -> Costar f d (m a) #

collectM :: Monad m => (a -> Costar f d b) -> m a -> Costar f d (m b) #

type Corep (Costar f) 
Instance details

Defined in Data.Profunctor.Rep

type Corep (Costar f) = f

Classes

class (Sieve p (Rep p), Strong p) => Representable (p :: Type -> Type -> Type) where #

A Profunctor p is Representable if there exists a Functor f such that p d c is isomorphic to d -> f c.

Associated Types

type Rep (p :: Type -> Type -> Type) :: Type -> Type #

Methods

tabulate :: (d -> Rep p c) -> p d c #

Instances
(Monad m, Functor m) => Representable (Kleisli m) 
Instance details

Defined in Data.Profunctor.Rep

Associated Types

type Rep (Kleisli m) :: Type -> Type #

Methods

tabulate :: (d -> Rep (Kleisli m) c) -> Kleisli m d c #

Functor f => Representable (Star f) 
Instance details

Defined in Data.Profunctor.Rep

Associated Types

type Rep (Star f) :: Type -> Type #

Methods

tabulate :: (d -> Rep (Star f) c) -> Star f d c #

Representable (Forget r) 
Instance details

Defined in Data.Profunctor.Rep

Associated Types

type Rep (Forget r) :: Type -> Type #

Methods

tabulate :: (d -> Rep (Forget r) c) -> Forget r d c #

Representable (Fold0Rep r) Source # 
Instance details

Defined in Data.Profunctor.Optic.Fold0

Associated Types

type Rep (Fold0Rep r) :: Type -> Type #

Methods

tabulate :: (d -> Rep (Fold0Rep r) c) -> Fold0Rep r d c #

Representable ((->) :: Type -> Type -> Type) 
Instance details

Defined in Data.Profunctor.Rep

Associated Types

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

Methods

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

Representable (LensRep a b) Source # 
Instance details

Defined in Data.Profunctor.Optic.Lens

Associated Types

type Rep (LensRep a b) :: Type -> Type #

Methods

tabulate :: (d -> Rep (LensRep a b) c) -> LensRep a b d c #

Representable (Traversal0Rep a b) Source # 
Instance details

Defined in Data.Profunctor.Optic.Traversal0

Associated Types

type Rep (Traversal0Rep a b) :: Type -> Type #

Methods

tabulate :: (d -> Rep (Traversal0Rep a b) c) -> Traversal0Rep a b d c #

class (Cosieve p (Corep p), Costrong p) => Corepresentable (p :: Type -> Type -> Type) where #

A Profunctor p is Corepresentable if there exists a Functor f such that p d c is isomorphic to f d -> c.

Associated Types

type Corep (p :: Type -> Type -> Type) :: Type -> Type #

Methods

cotabulate :: (Corep p d -> c) -> p d c #

Instances
Functor f => Corepresentable (Costar f) 
Instance details

Defined in Data.Profunctor.Rep

Associated Types

type Corep (Costar f) :: Type -> Type #

Methods

cotabulate :: (Corep (Costar f) d -> c) -> Costar f d c #

Corepresentable (Tagged :: Type -> Type -> Type) 
Instance details

Defined in Data.Profunctor.Rep

Associated Types

type Corep Tagged :: Type -> Type #

Methods

cotabulate :: (Corep Tagged d -> c) -> Tagged d c #

Corepresentable ((->) :: Type -> Type -> Type) 
Instance details

Defined in Data.Profunctor.Rep

Associated Types

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

Methods

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

Functor w => Corepresentable (Cokleisli w) 
Instance details

Defined in Data.Profunctor.Rep

Associated Types

type Corep (Cokleisli w) :: Type -> Type #

Methods

cotabulate :: (Corep (Cokleisli w) d -> c) -> Cokleisli w d c #

Corepresentable (GrateRep a b) Source # 
Instance details

Defined in Data.Profunctor.Optic.Grate

Associated Types

type Corep (GrateRep a b) :: Type -> Type #

Methods

cotabulate :: (Corep (GrateRep a b) d -> c) -> GrateRep a b d c #