SimpleH-0.9.1: A light, clean and powerful Haskell utility library

Safe HaskellNone

SimpleH.Functor

Description

A module for functors

Synopsis

Documentation

class Functor f whereSource

Methods

map :: (a -> b) -> f a -> f bSource

class Cofunctor f whereSource

Methods

comap :: (a -> b) -> f b -> f aSource

Instances

(Functor f, Cofunctor g) => Cofunctor (Compose f g) 
Cofunctor (Flip (->) a) 

class Bifunctor p whereSource

Methods

dimap :: (c -> a) -> (b -> d) -> p a b -> p c dSource

Instances

Bifunctor (->) 

newtype Id a Source

The Identity Functor

Constructors

Id 

Fields

getId :: a
 

newtype Const a b Source

The Constant Functor

Constructors

Const 

Fields

getConst :: a
 

Instances

Isomorphic a b (Const a c) (Const b c) 
Monoid a => Unit (Const a) 
Monoid a => Applicative (Const a) 
Functor (Const a) 
Semigroup (Const a b) 

newtype Flip f a b Source

A motherflippin' functor

Constructors

Flip 

Fields

unFlip :: f b a
 

Instances

Cofunctor (Flip (->) a) 
Isomorphic (f a b) (f c d) (Flip f b a) (Flip f d c) 

newtype Compose f g a Source

The Composition functor

Constructors

Compose 

Fields

getCompose :: f (g a)
 

Instances

Isomorphic (f (g a)) (f' (g' b)) (Compose f g a) (Compose f' g' b) 
(Unit f, Unit g) => Unit (Compose f g) 
(Traversable g, Monad f, Monad g) => Monad (Compose f g) 
(Applicative f, Applicative g) => Applicative (Compose f g) 
(Functor f, Functor g) => Functor (Compose f g) 
(Functor f, Cofunctor g) => Cofunctor (Compose f g) 
(Foldable f, Foldable g) => Foldable (Compose f g) 
(Traversable f, Traversable g) => Traversable (Compose f g) 
(Contravariant f, Monad f, Traversable g, MonadFix g) => MonadFix (Compose f g) 
(Applicative f, Monoid (g a)) => Monoid (Compose f g a) 
(Applicative f, Semigroup (g a)) => Semigroup (Compose f g a) 

newtype FProd f g a Source

Constructors

FProd 

Fields

getFProd :: f a :*: g a
 

Instances

(Unit f, Unit g) => Unit (FProd f g) 
(Applicative f, Applicative g) => Applicative (FProd f g) 
(Functor f, Functor g) => Functor (FProd f g) 

newtype Sum f g a Source

Constructors

Sum 

Fields

getSum :: f a :+: g a
 

Instances

(Functor f, Functor g) => Functor (Sum f g) 

(<$>) :: Functor f => (a -> b) -> f a -> f bSource

(|||) :: (Choice k, Functor (k a), Functor (k b)) => k a c -> k b d -> k (a :+: b) (c :+: d)Source

(<$) :: Functor f => b -> f a -> f bSource

(<&>) :: Functor f => f a -> (a -> b) -> f bSource

void :: Functor f => f a -> f ()Source

left :: (Choice k, Functor (k a), Functor (k d)) => k a c -> k (:+: a d) (:+: c d)Source

right :: (Choice k, Functor (k c), Functor (k b)) => k b d -> k (:+: c b) (:+: c d)Source

promap :: Cofunctor (Flip f c) => (a -> b) -> f b c -> f a cSource

map2 :: (Functor f, Functor f') => (a -> b) -> f (f' a) -> f (f' b)Source

map3 :: (Functor f, Functor f', Functor f'') => (a -> b) -> f (f' (f'' a)) -> f (f' (f'' b))Source