[m-users.] Higher-order predicates and functions and equivalence types.
Sean Charles (emacstheviking)
objitsu at gmail.com
Sat Aug 28 05:26:22 AEST 2021
Hi,
I have a type definition like this:
:- type tcon
---> tcon(
options :: felt_options,
output :: list(rop),
warnings :: lserror,
errors :: lserror,
render :: pred(instruction::in, string::in, string::out) is semidet
% ENV[] stack can go in here too
).
The `render` field, I wanted to be able to code this something like:
render :: foo
where foo would have been defined as
:- type foo = (pred(instruction::in, string::in, string::out) is semidet).
because I also wanted to be able to declare predicates that take a `foo` but it seems that I can’t do that. I’ve read Chapter 8 — Higher-order programming but I find my lack of familiarity with the terminology once again leaving me stumped.
I guess what I am after is something like the classic ‘pointer to a function returning an int’ in C.
How would I approach such a thing in Mercury?
Thank you,
Sean
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20210827/a78d4058/attachment.html>
More information about the users
mailing list