[m-users.] Multi predicate of entire enum

Ace sheganinans at gmail.com
Mon Jul 20 14:48:53 AEST 2020


Ok, thank you!

On Sun, Jul 19, 2020 at 9:44 PM Zoltan Somogyi <zoltan.somogyi at runbox.com>
wrote:

>
> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20200719/21fcbe25/attachment.html>


More information about the users mailing list