[m-users.] Possiblt stupid list question....

Zoltan Somogyi zoltan.somogyi at runbox.com
Wed Dec 22 03:52:54 AEDT 2021



On Tue, 21 Dec 2021 16:42:49 +0000, "Sean Charles (emacstheviking)" <objitsu at gmail.com> wrote:
> :- type rop
>     --->    t(string)
>     ;       tnl(string)
>     ;       nl
>     ;       tab(list(rop))
>     ;       rops(list(rop)).
> 
> By adding a new type constructor, which I have done,
> 
>     ;       seq(string, list())

Ah, we use the same phrase differently. For Mercury implementors,
a "type constructor" is something that constructs a new type
from zero or more other types. In your example, "rop" is the only
type constructor. Since it constructs a new type from nothing,
its an arity-0 type constructor. We would call "seq" a *data* constructor.
(Both phrases originate in the functional programming community.)
 
>         Call = rops([
>             t(FunctionName), t("("), seq(“, “, ArgsOut), t(")")
>         ]),

Yes, that would work.

I think compiler/error_util.m is close enough to what you are doing
that if you had a look, you might find some ideas worth stealing ...

Zoltan.





More information about the users mailing list