[m-users.] Error instance Mercury

Julien Fischer jfischer at opturion.com
Wed Jun 27 00:51:45 AEST 2018


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.


More information about the users mailing list