[m-users.] Error instance Mercury

Maxime Gautin maxime.gautin at gmail.com
Wed Jun 27 18:24:53 AEST 2018


Thank you for your help it works very well.

Maxime Gautin

Le mar. 26 juin 2018 à 16:51, Julien Fischer <jfischer at opturion.com> a
écrit :

>
> Hi,
>
> On Tue, 26 Jun 2018, Tomas By wrote:
>
> > On Tue, 26 Jun 2018 14:23:19 +0200, Maxime Gautin wrote:
> >> I have a compilation fail with the code I am studying. It is about an
> instance
> >> :- type token_list == list(token).
> >> :- instance parser_state(token_list) where [...]
> >
> > It's in the manual here
> >
> http://mercurylang.org/information/doc-release/mercury_ref/Instance-declarations.html#Instance-declarations
> >
> > "An ‘instance’ declaration gives a type for each parameter of the type
> > class. Each of these types must be either a type with no arguments, or
> > a polymorphic type whose arguments are all type variables. For example
> > int, list(T), bintree(K, V) and bintree(T, T) are allowed, but T and
> > list(int) are not. The types in an instance declaration must not be
> > abstract types which are elsewhere defined as equivalence types."
> >
> > You can do something like
> >
> > | :- type token_list ---> token_list(list(token)).
> >
> > (I think).
>
> You can very definitely do that -- the standard library does it
> in quite a few places.
>
> Julien.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20180627/976269ee/attachment.html>


More information about the users mailing list