[mercury-users] Brokenness with unique modes and impure lambda expressions

Peter Hawkins peter at hawkins.emu.id.au
Wed Aug 3 15:37:55 AEST 2005


Hi...

Why doesn't this work?

:- module test3.
:- interface.
:- import_module io.
:- pred main(io.state::di, io.state::uo) is det.
:- implementation.

    % An impure function taking a unique state
:- impure pred g_fn(io.state::di, io.state::uo) is det.
g_fn(!IO) :-
    promise_impure (
        io.print("hello world\n", !IO)
    ).

:- func get_closure =     ((impure pred(io.state, 
io.state))::out(pred(di, uo) is det)) is det.
get_closure = F :-
    promise_pure (
        F = (impure pred(IO0::di, IO::uo) is det :-
            impure call(g_fn, IO0, IO))
    ).

main(!IO) :-
    promise_pure (
        impure call(get_closure, !IO)
    ).

=)
Peter
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list