Files
mercury/tests/hard_coded/ho_func_reg.m
Simon Taylor f68441c80f Fix some errors in the function declarations found by
Estimated hours taken: 0.1

tests/hard_coded/ho_func_reg.m
	Fix some errors in the function declarations found by
	Fergus' recent changes to prog_io.m.
1997-07-24 01:02:16 +00:00

42 lines
864 B
Mathematica

% Regression test:
%
% This program uses a higher order function. Due to the way higher order
% types are represented as terms (which is quite different from any
% other type) manipulations of types that don't take this into account
% would make mistakes.
%
% The Mercury compiler of 20 December, 1996 failed to compile this,
% giving link errors.
:- module ho_func_reg.
:- interface.
:- import_module int, io.
:- pred main(io__state::di, io__state::uo) is det.
:- type bar == (func(int) = int).
:- inst bar = (func(in) = out is det).
:- func foo(bar, int) = int.
:- mode foo(in(bar), in) = out is det.
:- func next(int) = int.
:- implementation.
main -->
io__write_string("I seem to have compiled ok.\n"),
{ Eight = foo(next, 7) },
io__write_int(Eight),
io__write_string(" seems to be the answer\n").
next(I) = I + 1.
foo(F, I) = apply(F, I).