[m-users.] How to declare a set of typeclasses?

"Sean Charles (emacstheviking)" <[email protected]>
Newsgroups gmane.comp.lang.mercury.general
Message-ID <[email protected]>
having read 4.2.2 Equivalence types, I see that it is possible to create an equivalence type using type abbreviations but I can't figure out how to get one to work for a parameterised type class using sets.

:- type l1_set(T) == set(hittable(T)).

gives error:
	level_ufo.m:804: In definition of type `l1_set'/1:
	level_ufo.m:804:   error: undefined type `hittable'/1.

which is clear; hittable is indeed not a type, it's a typeclass, this was a deliberate 'process of elimination' for my thought process!

Then I did what I thought would work:

:- type l1_set(T) == set(hittable(T)) <= hittable(T).

but this gives the error:
	level_ufo.m:804: On the left hand side of type definition: error: type
	level_ufo.m:804:   parameters must be variables, but
	level_ufo.m:804:   `(l1_set(T) == set(hittable(T)))' and `hittable(T)' are not.

And here is the actual code where I am trying to use it, I am operating on the assumption that by default Mercury has some way of creating a unique hash for each object in the set to know what insert_new should do the right thing. I read "4.5. The Standard ordering" but I can't remember where I am sure I've seen about overriding this behaviour, it mentioned Haskell I think. Ah.. it is section 3.8 of the online page https://mercury-in.space/crash.html#orga13c54a

What am I not doing correctly? Is it possible?

Thanks,
Sean.

_______________________________________________
users mailing list
[email protected]
https://lists.mercurylang.org/listinfo/users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.