[m-users.] How to declare a set of typeclasses?
Sean Charles (emacstheviking)
objitsu at gmail.com
Wed Oct 11 09:19:38 AEDT 2023
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20231010/eebfa6f3/attachment.html>
More information about the users
mailing list