[m-users.] Error instance Mercury

Tomas By tomas at basun.net
Tue Jun 26 22:51:11 AEST 2018


Hello,

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).

/Tomas


More information about the users mailing list