mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-16 01:43:35 +00:00
29 lines
571 B
Mathematica
29 lines
571 B
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- module call_failure.
|
|
:- interface.
|
|
|
|
:- pred foo(int::in, int::out) is failure.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module int.
|
|
:- import_module require.
|
|
|
|
foo(X, Y) :-
|
|
( if X = 42 then
|
|
bar(X, Y0),
|
|
Y = Y0 + 1
|
|
else
|
|
error("foo")
|
|
).
|
|
|
|
:- pred bar(int, int).
|
|
:- mode bar(in(bound(42)), out) is failure.
|
|
:- pragma no_inline(bar/2).
|
|
|
|
bar(42, _) :-
|
|
fail.
|