Coal.Combinators
Combinators and tuple operations for functional programming.
identity
The identity function.
Returns the value unchanged.
identity : a -> aidentity : a -> a
always
When applied to one argument, return a function that always returns this value.
always : a -> b -> aalways : a -> b -> a
fst
Extract the first element of a pair.
fst : (a, b) -> afst : (a, b) -> a
snd
Extract the second element of a pair.
snd : (a, b) -> bsnd : (a, b) -> b
apply_fst
Apply a function to the first element of a pair.
apply_fst : (a -> b) -> (a, c) -> (b, c)apply_fst : (a -> b) -> (a, c) -> (b, c)
apply_snd
Apply a function to the second element of a pair.
apply_snd : (b -> c) -> (a, b) -> (a, c)apply_snd : (b -> c) -> (a, b) -> (a, c)
swap
Swap the components of a pair.
swap : (a, b) -> (b, a)swap : (a, b) -> (b, a)
fst3
Extract the first element of a triple.
fst3 : (a, b, c) -> afst3 : (a, b, c) -> a
snd3
Extract the second element of a triple.
snd3 : (a, b, c) -> bsnd3 : (a, b, c) -> b
thd3
Extract the third element of a triple.
thd3 : (a, b, c) -> cthd3 : (a, b, c) -> c
curry
Convert a function that takes a pair into one that takes two arguments.
curry : ((a, b) -> c) -> a -> b -> ccurry : ((a, b) -> c) -> a -> b -> c
uncurry
Convert a function of two arguments into one that takes a pair.
uncurry : (a -> b -> c) -> (a, b) -> cuncurry : (a -> b -> c) -> (a, b) -> c
flip
Reverse the order of the arguments to a two-argument function.
flip : (a -> b -> c) -> b -> a -> cflip : (a -> b -> c) -> b -> a -> c
iterate
Apply the function f to the value x, n times.
iterate : nat -> (a -> a) -> a -> aiterate : nat -> (a -> a) -> a -> a