[mercury-users] type (class?) parameters

Richard A. O'Keefe ok at atlas.otago.ac.nz
Mon Oct 16 12:26:50 AEDT 2000


	> (b) Represent numbers as types, e.g. using unary notation.
	
	Heh didn't think of this, it seems to crop up quite a lot recently. Have
	to give it a try :) Though perhaps vector(succ(succ(succ(zero))), float)
	is not quite as succinct as vector(3, float)...
	
There's no need to use unary for types.  A good way to represent numbers as
sum-of-product types is nat = z | tp1 nat | tp2 nat (0 | 2x+1 | 2x+2) where
each natural number has a unique representation.  It works just as well as a
type.

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