mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-19 19:33:46 +00:00
34 lines
683 B
Mathematica
34 lines
683 B
Mathematica
% vim: ts=4 sw=4 et ft=mercury
|
|
|
|
:- module require_det_in_lambda.
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io::di, io::uo) is det.
|
|
|
|
:- implementation.
|
|
:- import_module int.
|
|
|
|
main(!IO) :-
|
|
% The compiler did not look for violations of require_detism scopes inside
|
|
% lambda goals.
|
|
T = (pred(X::in, Y::out) is semidet :-
|
|
require_det (
|
|
X < 10,
|
|
Y = X + 1
|
|
)
|
|
),
|
|
test(T, 5, !IO).
|
|
|
|
:- pred test((pred(int, int))::in(pred(in, out) is semidet), int::in,
|
|
io::di, io::uo) is det.
|
|
|
|
test(T, A, !IO) :-
|
|
( T(A, B) ->
|
|
io.write_int(B, !IO),
|
|
io.nl(!IO)
|
|
;
|
|
io.write_string("test failed\n", !IO)
|
|
).
|