product-profunctors-0.11.0.2: product-profunctors
Safe HaskellNone
LanguageHaskell2010

Data.Profunctor.Product.Examples

Synopsis

Documentation

newtype Replicator r f a b Source #

Constructors

Replicator (r -> f b) 

Instances

Instances details
Functor f => Profunctor (Replicator r f) Source # 
Instance details

Defined in Data.Profunctor.Product.Examples

Methods

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

lmap :: (a -> b) -> Replicator r f b c -> Replicator r f a c #

rmap :: (b -> c) -> Replicator r f a b -> Replicator r f a c #

(#.) :: forall a b c q. Coercible c b => q b c -> Replicator r f a b -> Replicator r f a c #

(.#) :: forall a b c q. Coercible b a => Replicator r f b c -> q a b -> Replicator r f a c #

Applicative f => ProductProfunctor (Replicator r f) Source # 
Instance details

Defined in Data.Profunctor.Product.Examples

Methods

purePP :: b -> Replicator r f a b Source #

(****) :: Replicator r f a (b -> c) -> Replicator r f a b -> Replicator r f a c Source #

empty :: Replicator r f () () Source #

(***!) :: Replicator r f a b -> Replicator r f a' b' -> Replicator r f (a, a') (b, b') Source #

Applicative f => Default (Replicator (f b) f) b b Source # 
Instance details

Defined in Data.Profunctor.Product.Examples

Methods

def :: Replicator (f b) f b b Source #

Functor f => Functor (Replicator r f a) Source # 
Instance details

Defined in Data.Profunctor.Product.Examples

Methods

fmap :: (a0 -> b) -> Replicator r f a a0 -> Replicator r f a b #

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

Applicative f => Applicative (Replicator r f a) Source # 
Instance details

Defined in Data.Profunctor.Product.Examples

Methods

pure :: a0 -> Replicator r f a a0 #

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

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

(*>) :: Replicator r f a a0 -> Replicator r f a b -> Replicator r f a b #

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

replicateT :: Default (Replicator r f) b b => r -> f b Source #

A higher-order generalisation of replicate. For example

foo :: IO (String, String, String)
foo = replicateT getLine
> foo
Hello
world
!
("Hello","world","!")

newtype Take a z b Source #

Constructors

Take ([a] -> Maybe ([a], b)) 

Instances

Instances details
Profunctor (Take a) Source # 
Instance details

Defined in Data.Profunctor.Product.Examples

Methods

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

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

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

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

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

ProductProfunctor (Take a) Source # 
Instance details

Defined in Data.Profunctor.Product.Examples

Methods

purePP :: b -> Take a a0 b Source #

(****) :: Take a a0 (b -> c) -> Take a a0 b -> Take a a0 c Source #

empty :: Take a () () Source #

(***!) :: Take a a0 b -> Take a a' b' -> Take a (a0, a') (b, b') Source #

Default (Take a) z a Source # 
Instance details

Defined in Data.Profunctor.Product.Examples

Methods

def :: Take a z a Source #

Functor (Take a z) Source # 
Instance details

Defined in Data.Profunctor.Product.Examples

Methods

fmap :: (a0 -> b) -> Take a z a0 -> Take a z b #

(<$) :: a0 -> Take a z b -> Take a z a0 #

Applicative (Take a z) Source # 
Instance details

Defined in Data.Profunctor.Product.Examples

Methods

pure :: a0 -> Take a z a0 #

(<*>) :: Take a z (a0 -> b) -> Take a z a0 -> Take a z b #

liftA2 :: (a0 -> b -> c) -> Take a z a0 -> Take a z b -> Take a z c #

(*>) :: Take a z a0 -> Take a z b -> Take a z b #

(<*) :: Take a z a0 -> Take a z b -> Take a z a0 #

takeT :: Default (Take a) b b => [a] -> Maybe b Source #

A type safe generalisation of take. For example

> let count = [1..] :: [Int]
> takeT count :: Maybe (Int, Int)
Just (1,2)
> takeT count
    :: Maybe (Int, Int, (Int, (Int, Int), Int, Int),
              Const Int Bool, Identity (Int, Int), Tagged String Int)
Just (1,2,(3,(4,5),6,7),Const 8,Identity (9,10),Tagged 11)

newtype Traverse f a b Source #

Constructors

Traverse 

Fields

Instances

Instances details
Functor f => Profunctor (Traverse f) Source # 
Instance details

Defined in Data.Profunctor.Product.Examples

Methods

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

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

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

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

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

Applicative f => ProductProfunctor (Traverse f) Source # 
Instance details

Defined in Data.Profunctor.Product.Examples

Methods

purePP :: b -> Traverse f a b Source #

(****) :: Traverse f a (b -> c) -> Traverse f a b -> Traverse f a c Source #

empty :: Traverse f () () Source #

(***!) :: Traverse f a b -> Traverse f a' b' -> Traverse f (a, a') (b, b') Source #

Default (Traverse f) (f a) a Source # 
Instance details

Defined in Data.Profunctor.Product.Examples

Methods

def :: Traverse f (f a) a Source #

Functor f => Functor (Traverse f a) Source # 
Instance details

Defined in Data.Profunctor.Product.Examples

Methods

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

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

Applicative f => Applicative (Traverse f a) Source # 
Instance details

Defined in Data.Profunctor.Product.Examples

Methods

pure :: a0 -> Traverse f a a0 #

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

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

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

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

traverseT :: Default (Traverse f) a b => a -> f b Source #

Use sequenceT instead. It has a better name.

type Sequence = Traverse Source #

Actually, Sequence is a better name for this

sequenceT :: Default (Sequence f) a b => a -> f b Source #

A higher-order generalisation of sequenceA. For example

> sequenceT (print 3110, putStrLn World) :: IO ((), ())
3110
World
((),())

newtype Zipper a b Source #

Constructors

Zipper 

Fields

Instances

Instances details
Profunctor Zipper Source # 
Instance details

Defined in Data.Profunctor.Product.Examples

Methods

dimap :: (a -> b) -> (c -> d) -> Zipper b c -> Zipper a d #

lmap :: (a -> b) -> Zipper b c -> Zipper a c #

rmap :: (b -> c) -> Zipper a b -> Zipper a c #

(#.) :: forall a b c q. Coercible c b => q b c -> Zipper a b -> Zipper a c #

(.#) :: forall a b c q. Coercible b a => Zipper b c -> q a b -> Zipper a c #

ProductProfunctor Zipper Source # 
Instance details

Defined in Data.Profunctor.Product.Examples

Methods

purePP :: b -> Zipper a b Source #

(****) :: Zipper a (b -> c) -> Zipper a b -> Zipper a c Source #

empty :: Zipper () () Source #

(***!) :: Zipper a b -> Zipper a' b' -> Zipper (a, a') (b, b') Source #

a ~ b => Default Zipper [a] b Source # 
Instance details

Defined in Data.Profunctor.Product.Examples

Methods

def :: Zipper [a] b Source #

Functor (Zipper a) Source # 
Instance details

Defined in Data.Profunctor.Product.Examples

Methods

fmap :: (a0 -> b) -> Zipper a a0 -> Zipper a b #

(<$) :: a0 -> Zipper a b -> Zipper a a0 #

Applicative (Zipper a) Source # 
Instance details

Defined in Data.Profunctor.Product.Examples

Methods

pure :: a0 -> Zipper a a0 #

(<*>) :: Zipper a (a0 -> b) -> Zipper a a0 -> Zipper a b #

liftA2 :: (a0 -> b -> c) -> Zipper a a0 -> Zipper a b -> Zipper a c #

(*>) :: Zipper a a0 -> Zipper a b -> Zipper a b #

(<*) :: Zipper a a0 -> Zipper a b -> Zipper a a0 #

cl_map :: Default Zipper a b => (b -> r) -> a -> [r] Source #

A challenge from a Clojurist on Hacker News (https:/news.ycombinator.comitem?id=23939350)

> cl_map (uncurry (+)) ([1,2,3], [4,5,6])
[5,7,9]

> cl_map (+3) [1,2,3]
[4,5,6]

> let max3 (x, y, z) = x max y max z
> cl_map max3 ([1,20], [3,4], [5,6])
[5,20]