class Functor f  where

A Functor is a type constructor which supports a mapping operation (<$>).

(<$>) can be used to turn functions a -> b into functions f a -> f b whose argument and return types use the type constructor f to represent some computational context.

Instances must satisfy the following laws:

  • Identity: (<$>) id = id
  • Composition: (<$>) (f <<< g) = (f <$>) <<< (g <$>)


  • map :: forall a b. (a -> b) -> f a -> f b



Operator alias for (left-associative / precedence 4)


mapFlipped :: forall f a b. Functor f => f a -> (a -> b) -> f b

mapFlipped is map with its arguments reversed. For example:

[1, 2, 3] <#> \n -> n * n


Operator alias for Data.Functor.mapFlipped (left-associative / precedence 1)


void :: forall f a. Functor f => f a -> f Unit

The void function is used to ignore the type wrapped by a Functor, replacing it with Unit and keeping only the type information provided by the type constructor itself.

void is often useful when using do notation to change the return type of a monadic computation:

main = forE 1 10 \n -> void do
  print n
  print (n * n)


voidRight :: forall f a b. Functor f => a -> f b -> f a

Ignore the return value of a computation, using the specified return value instead.


Operator alias for Data.Functor.voidRight (left-associative / precedence 4)


voidLeft :: forall f a b. Functor f => f a -> b -> f b

A version of voidLast with its arguments flipped.


Operator alias for Data.Functor.voidLeft (left-associative / precedence 4)