Many frequently-used functions and infix operators, similar to frequently-used types, are predefined in Curry. Some of these can be found in the “Prelude”, a Curry source program automatically loaded when the compiler/interpreter starts. A few others are so fundamental that they are built into the language. Some of these functions and operators are shown in the following table.
Description | Ident. | Fix. | Prec. | Type |
---|---|---|---|---|
Boolean equality | == | 4 | a -> a -> Bool | |
Constrained equality | =:= | 4 | a -> a -> Bool | |
Boolean conjunction | && | R | 3 | Bool -> Bool -> Bool |
Boolean disjunction | || | R | 2 | Bool -> Bool -> Bool |
Parallel conjunction | & | R | 0 | Bool -> Bool -> Bool |
Constrained expression | &> | R | 0 | Bool -> a -> a |
Because of non-determinism and free variables, in the following discussion,
different evaluations of the same expression may produce different values.
The Boolean equality
applied to expressions and , i.e.,
, returns “True”
when and evaluate to the
same value and “False” when they
evaluate to different values—a
more precise definition will be given later.
If the evaluation of and/or ends in an expression that
still contains functions, e.g., 1 ‘div‘ 0, the computation
fails and no value is returned.
The constrained equality
applied to expressions and , i.e.,
returns “True”
when and evaluate to the
same value—a precise definition will be given later.
Otherwise, the computation fails and no value is returned.
A key difference between the Boolean and the constrained equalities
is how they evaluate expressions containing variables.
This will be discussed in some detail in Section 3.14.1.
The Boolean conjunction
applied to expressions and , i.e.,
, returns “True”
when and evaluate to “True”.
The Boolean disjunction
applied to expressions and , i.e.,
, returns “True”
when or evaluate to “True”.
The parallel conjunction
applied to expressions and , i.e.,
, evaluates and concurrently.
If both succeeds, the evaluation succeeds;
otherwise it fails.
The constrained expression
applied to a constraint and an expression , i.e.,
, evaluates first and, if evaluates
to “True”, then the result is the value of , otherwise it fails.
Curry predefines many more functions and operations, e.g., the standard arithmetic and relational operators on numbers. A complete list can be found both in the Report and the “Prelude”.