std.function

Conveniences for working with functions.

Values

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

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

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 a a0 . a -> a0 -> a

const x creates a function that always returns x

let flip f x y : forall a a0 a1 . (a -> a0 -> a1) -> a0 -> a -> a1

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

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

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

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

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

let << : forall a a0 a1 . (a -> a0) -> (a1 -> a) -> a1 -> a0

Right-to-left function composition

let >> : forall a a0 a1 . (a -> a0) -> (a0 -> a1) -> a -> a1

Left-to-right function composition