General combinators¶

These are general functions, which do not pertain to any domain in particular. They are typically used in combination with other functions.

id : a -> a¶

The identity function, which simply returns whatever input it is given.

val a = id 14
//    = 14
val b = id "some text"
//    = "some text"


const : a -> b -> a¶

const x is a function which returns x no matter what input it is given, i.e., the constant x function.

val x = const 30 100
//    = 30
val f = const 0
//    = \_ -> 0


flip : (a -> b -> c) -> b -> a -> c¶

Flips the order of the first two arguments of a function.

Examples¶

val a = flip (\x -> \y -> x) 10 20
//    = 20