62 CHAPTER C. Common Functions (file misc.toy)
false ‘or‘ false = false
% Sequential and
false /\ _ = false
true /\ X = X
% Sequential or
true \/ X = true
false \/ X = X
% Negation
not true = false
not false = true
andL, orL ,orL’ :: [bool] -> bool
andL = foldr (/\) true
orL = foldr or false
orL’ = foldr (\/) false
% orL’ is ’stricter’, but more deterministic, than orL
any, any’,all :: (A -> bool) -> [A] -> bool
any P = orL . (map P)
any’ P = orL’ . (map P)
% any’ is ’stricter’, but more deterministic, than any
all P = andL . (map P)
undefined :: A
undefined = if false then undefined
% (def X) is true if X is finite and totally defined
def X :- X == _
% (not_undef X) is true if X is not undefined
not_undef X :- X /= _
% (nf X) is the identity, restricted to finite and totally defined values
% Operationally, (nf X) forces the computation of a normal form for X,
% if it exists.
nf X = Y <== X==Y
% (hnf X) is the identity, restricted to not undefined values.
% Operationally, (hnf X) forces the computation of a head normal form for X,
% if it exists.
Comentarios a estos manuales