Files
mercury/tests/invalid/nullary_ho_func_error.m
Fergus Henderson be4b9f1d20 Allow zero-arity higher-order function terms.
compiler/typecheck.m:
compiler/modecheck_unify.m:
	Allow apply/1.

compiler/mercury_to_mercury.m:
	Fix the output of nullary higher-order function insts:
	previously it would output `(func() = Mode is Det)',
	but the correct output is `((func) = Mode is Det)'.

doc/reference_manual.texi:
	Document that zero-arity higher-order function
	types, insts, modes, lambda expressions, and applications
	are allowed.

tests/hard_coded/Mmake:
tests/hard_coded/nullary_ho_func.m:
tests/hard_coded/nullary_ho_func.exp:
tests/invalid/Mmake:
tests/invalid/nullary_ho_func_error.m:
tests/invalid/nullary_ho_func_error.err_exp:
	Test cases relating to the above change.
1997-07-23 15:37:01 +00:00

29 lines
578 B
Mathematica

% Test case for use of zero-arity higher-order function terms.
%
% Author: fjh
:- module nullary_ho_func_error.
:- interface.
:- import_module io.
:- pred main(io__state::di, io__state::uo) is det.
:- implementation.
:- func pi = float.
pi = 3.14159.
main -->
print("apply_nullary_func(pi) = "),
% this would be legal:
% print(apply_nullary_func((func) = pi)), nl.
% this one is not:
print(apply_nullary_func(pi)), nl.
:- func apply_nullary_func((func) = T) = T.
:- mode apply_nullary_func(in((func) = out is det)) = out is det.
apply_nullary_func(F) = apply(F).