[m-users.] Multi predicate of entire enum
Zoltan Somogyi
zoltan.somogyi at runbox.com
Mon Jul 20 14:44:42 AEST 2020
2020-07-20 14:37 GMT+10:00 "Ace" <sheganinans at gmail.com>:
> So say I have some enum:
>
> `:- type ex ---> a; b; c.`
>
> And I want to generate a function similar to:
>
> ```
> :- pred ex_mul(ex::out) is multi.
> ex_mul(a).
> ex_mul(b).
> ex_mul(c).
> ```
>
> Any kind of standard library predicate I can use so I don't have to add a
> new case to the predicate for every instance of the enum?
No, there is no such library predicate.
If updating the predicate manually becomes too much of a bother,
you could write a script (in sh, python, perl or something else) that
generates the definition of both the type and the predicate from
a single authoritative source in another file.
Zoltan.
More information about the users
mailing list