60 CHAPTER B. Declaration of Primitives (file basic.toy)
:: real -> real -> real
% integer powers
primitive (^) :: real -> int -> real
% binary integer functions
primitive div, mod, gcd :: int -> int -> int
% rounding and truncating functions
primitive round,trunc,floor,ceiling :: real -> int
% integer to real conversion
primitive toReal :: int -> real
% relational operators
primitive (<),(<=),(>),(>=) :: real -> real -> bool
% equality and disequality functions
primitive (==),(/=) :: A -> A -> bool
% infix operator precedences
infix 90 ^,**
infix 80 /
infixl 80 *
infixl 70 +,-
infix 50 < ,<=,>,>=
infix 20 ==, /=
% ’if_then_else’ and ’if_then’ functions are equivalent to the ’sugar syntax’
% functions if .. then .. else and if .. then, but useful as partial functions
if_then_else :: bool -> A -> A -> A
if_then_else true X Y = X
if_then_else false X Y = Y
if_then :: bool -> A -> A
if_then true X = X
% ’flip’ function is necessary for syntax sections management .
flip :: (A -> B -> C) -> B -> A -> C
flip F X Y = F Y X
Comentarios a estos manuales