mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 09:23:44 +00:00
44 lines
832 B
Mathematica
44 lines
832 B
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% Compiling this module should generate an error message since
|
|
% it tries to cast a non-standard func inst to ground.
|
|
|
|
:- module ho_default_func_4.
|
|
|
|
:- interface.
|
|
:- import_module io.
|
|
|
|
:- pred main(io::di, io::uo) is det.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module int.
|
|
:- import_module univ.
|
|
|
|
:- inst one == bound(1).
|
|
|
|
main(!IO) :-
|
|
baz(foo, F),
|
|
io.write_int(F(42), !IO),
|
|
io.nl(!IO).
|
|
|
|
:- func foo(int) = int.
|
|
|
|
foo(X) = X + 1.
|
|
|
|
:- func bar(int) = int.
|
|
:- mode bar(in(one)) = out is det.
|
|
|
|
bar(X) = X.
|
|
|
|
:- pred baz(T::in, T::out) is det.
|
|
|
|
baz(X, Y) :-
|
|
( if univ_to_type(univ(bar), Y0) then
|
|
Y = Y0
|
|
else
|
|
Y = X
|
|
).
|