[mercury-users] Records
Simon Taylor
stayl at cs.mu.OZ.AU
Wed Nov 3 14:17:30 AEDT 1999
> it's a very minor point, but `:=' smacks too much of assignment to me.
> But any other notation I can think up off the top of my head is less
> clear.
I agree with that.
> Question no.1: can I do something like
>
> FieldName = field1,
> Field1 = X1 ^ FieldName
No. The current implementation needs to know at compile time
which field is being extracted so that it can generate the
corresponding unifications.
> Question no.2: are typeclasses going to be extended to have fields?
> e.g.
>
> :- typeclass foo(T) where [
> a_field :: int,
> pred foo...
> ].
This would be a bit tricky. The current implementation expands
the record syntax into unifications before mode checking,
so it doesn't have to work out what the modes of the arguments of the
field extraction and update "functions" should be. This wouldn't
be possible with typeclasses.
One possible solution would be for the user to specify the modes.
e.g.
:- typeclass foo(T) where [
a_field :: int
with [
get(in) = out is det,
get(ui) = out is det,
set(in, in) = out is det,
set(di, di) = uo is det
],
pred foo ...
].
Simon.
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list