std.function

Conveniences for working with functions.

Values

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

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

#[implicit]
let category : Category (->)

#[implicit]
let functor : forall a . 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

#[implicit]
let applicative : forall a . 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

#[implicit]
let monad : forall a . 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

#[infix(right, 0)]
let <| f x : forall b a . (a -> b) -> a -> b

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

#[infix(left, 0)]
let |> x f : forall b a . a -> (a -> b) -> b

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

#[infix(right, 9)]
let << : forall a c b . (b -> c) -> (a -> b) -> a -> c

Right-to-left function composition

#[infix(left, 9)]
let >> : forall c b a . (a -> b) -> (b -> c) -> a -> c

Left-to-right function composition