[m-users.] Cannot execute a predicate from a Discriminated Union

Charles Shuller charles.shuller at gmail.com
Sun Jun 28 07:47:22 AEST 2015

Hello All,

I can't get a predicate to execute from a discriminated union after passing
the type as a parameter into a predicate.  Though it works just fine from

I've tried everything I can think of with modes and insts on the DU, but
nothing has worked, any insight would be much appreciated.

:- type test
    ---> test(test_name::string,

:- pred execute_test(test::in, disposition::out, io::di, io::uo) is det.
execute_test(Test, Disposition, !IO) :-
    call(Test^test_pred, Disposition), %% Compilation fails here
    Disposition = fail(Test^test_name ++ " Failed to execute").

main(!IO) :-
    Test = test("PassTest", pass_test),
    call(Test^test_pred, Disposition). %% This works just fine though

Compiler Output (14.01.1)

manual_test.m:044: In clause for `execute_test(in, out, di, uo)':
manual_test.m:044:   in argument 1 (i.e. the predicate term) of higher-order
manual_test.m:044:   predicate call:
manual_test.m:044:   mode error: variable `V_10' has instantiatedness
manual_test.m:044:   expecting higher-order pred inst (of arity 1).


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20150627/9be06a45/attachment.html>

More information about the users mailing list