[mercury-users] constructor class syntax

David Glen JEFFERY dgj at hydra.cs.mu.oz.au
Wed Nov 3 15:29:15 AEDT 1999


On 03-Nov-1999, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> On 02-Nov-1999, Michael Day <mikeday at corplink.com.au> wrote:
> > 
> > :- class ordered_container(C(T)) <= container(C), ordered(T) where
> > 	[
> > 		func lowest_element(C(T)) = T,
> > 		func highest_element(C(T)) = T,
> > 		...
> > 		and so forth
> > 	].
> > 
> > 
> > Does that syntax look at all realistic, or possible?
> 
> I'm not sure what that syntax is supposed to mean.
> How would it differ from say
> 
> 	:- typeclass ordered_container(C) <= container(C) where
> 		[
> 			func lowest_element(C(T)) = T <= ordered(T),
> 			func highest_element(C(T)) = T <= ordered(T),
> 			...
> 			and so forth
> 		].

I think that what Michael is trying to express is:

:- typeclass ordered_container(C, T) <= container(C), ordered(T) where
[
	func lowest_element(C(T)) = T <= ordered(T),
	func highest_element(C(T)) = T <= ordered(T),
	...
	and so forth
].

The important thing to note is that the first parameter is a type constructor,
while the second parameter is a type. You can find the rationale for this
design of a bulk types library in [3].

> Anyway, here's some references to related work:
> 
> [1] John Hughes, Restricted Datatypes in Haskell. Appeared in the 1999 Haskell Workshop.
> 	<http://www.cs.chalmers.se/~rjmh/Papers/restricted-datatypes.ps>.
> [2] Mark Jones, Type Classes and Functional Dependencies.
> 	<http://www.cse.ogi.edu/~mpj/fds.html>.
> 
> The bibliography for [1] probably has good references to prior related work.

You should also check out:

[3]SL Peyton Jones, "Bulk Types with class", Electronic proceedings of the 1996
Glasgow Functional Programming Workshop,
http://www.dcs.gla.ac.uk/workshops/fpw96/Proceedings96.html


dgj
-- 
David Jeffery (dgj at cs.mu.oz.au) | If your thesis is utterly vacuous
PhD student,                    | Use first-order predicate calculus.
Dept. of Comp. Sci. & Soft. Eng.|     With sufficient formality
The University of Melbourne     |     The sheerist banality
Australia                       | Will be hailed by the critics: "Miraculous!"
                                |     -- Anon.
--------------------------------------------------------------------------
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