Files
mercury/tests/valid/some_switch.m
Zoltan Somogyi 422229600d Fix indentation.
2019-05-28 23:04:35 +02:00

31 lines
656 B
Mathematica

%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et ft=mercury
%---------------------------------------------------------------------------%
%
% Test of switch detection with explicit existential quantification.
:- module some_switch.
:- interface.
:- type nat
---> o
; s(nat).
:- func add(nat, nat) = nat.
:- mode add(in, in) = in is semidet.
:- mode add(out, out) = in is multi.
:- mode add(in, in) = out is det.
:- implementation.
add(X, Y) = Z :-
(
X = o,
Z = Y
;
some [Xp] (
X = s(Xp),
Z = s(add(Xp, Y))
)
).