std.function

Conveniences for working with functions.

Values

let semigroup s : forall a b . std.semigroup.Semigroup b -> std.semigroup.Semigroup (a -> b)

let monoid m : forall a b . std.monoid.Monoid b -> std.monoid.Monoid (a -> b)

let category : std.category.Category (->)

let functor : forall a . std.functor.Functor ((->) a)

A Functor represents an action on a parameterized type which does not change the structure with the mapped type.

The following laws should hold:

  • map id == id
  • map (f << g) == map f << map g

let applicative : forall a . std.applicative.Applicative ((->) a)

A Functor with application.

The following laws should hold:

  • wrap id <*> v = v
  • wrap (<<) <> u <> v <> w = u <> (v <*> w)
  • wrap f <*> wrap x = wrap (f x)
  • u <> wrap y = wrap (\g -> g x) <> u

let monad : forall a . std.monad.Monad ((->) a)

A generalised interface for imperatively sequencing actions

let id : forall a . a -> a

The identity function, where id x == x

let const : forall b a . a -> b -> a

const x creates a function that always returns x

let flip f x y : forall c b a . (a -> b -> c) -> b -> a -> c

flip f creates a new function that takes its two arguments in reverse order

let <| f x : forall b a . (a -> b) -> a -> b

Backward function application, where f <| x == f x

let |> x f : forall b a . a -> (a -> b) -> b

Forward function application, where x |> f == f x

let << : forall a c b . (b -> c) -> (a -> b) -> a -> c

Right-to-left function composition

let >> : forall c b a . (a -> b) -> (b -> c) -> a -> c

Left-to-right function composition