FR
PréludeChargé par défaut — aucun import nécessaire.

Basic functions

Synopsis
id : a -> a

The identity function: returns its argument unchanged.

const : a -> b -> a

const x y = x. Ignores its second argument. Useful for passing to higher-order functions: map (const 0) xs.

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

flip f x y = f y x. Swaps the arguments of a binary function.

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

Function composition: (f . g) x = f (g x). infixr 9 (binds tighter than any arithmetic operator), so f . g . h is f . (g . h).

uncurry : (a -> b -> c) -> (a, b) -> c

Turn a curried function into one taking a pair.

curry : ((a, b) -> c) -> a -> b -> c

Turn a function on pairs into a curried function.

($) : (a -> b) -> a -> b

Low-precedence application: f $ x is just f x. Because $ binds looser than everything (infixr 0), it lets you drop the parentheses around a whole trailing argument: printLine $ show (1 + 2) rather than printLine (show (1 + 2)).

(|>) : a -> (a -> b) -> b

Reverse application ("pipe"): x |> f is f x. Reads left to right — the data first, then the steps: [1, 2, 3] |> map double |> sum.