[mercury-users] Higher-order insts

Peter Hawkins peter at hawkins.emu.id.au
Wed May 19 14:26:21 AEST 2004


Hi...

Is there a way of storing a closure including higher-order insts in a data 
structure and getting it back again? I'm trying to do this:

:- type something.

:- inst mypred = (pred(in, out) is semidet).
:- type mypred = (pred(something, set(something))).
:- mode mypredin == (mypred >> mypred).
:- mode mypredout == (free >> mypred).

:- type athing ---> a(
	moo :: mypred
).

:- func new_athing(mypred) = athing.
:- mode new_athing(mypredin) = out.
new_athing(Moo) = a(Moo).

:- func get_moo(athing) = moo.
:- mode get_moo(in) = mypredout.
get_moo(AThing) = AThing ^ Moo.

But it fails with an error like this:
things.m:098: In clause for `get_moo(in) = (things.mypredout)'
:
things.m:098:   mode error: argument 2 did not get sufficiently instantiated.
things.m:098:   Final instantiatedness of `HeadVar__2' was `ground',
things.m:098:   expected final instantiatedness was `(pred((ground -> ground), 
(free -> ground)) is semidet)'.

Is what I am trying to do possible?

=)
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