[mercury-users] type (class?) parameters

Peter Ross petdr at miscrit.be
Mon Oct 16 23:27:50 AEDT 2000


On Mon, Oct 16, 2000 at 10:12:27PM +1100, Michael Day wrote:
> 
> > 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.
> 
> I'm afraid I can't quite follow that, particularly tp2 (is that Haskell
> syntax?) What do tp1 and tp2 stand for?
> 
> :- type nat ---> zero ; tp1(nat) ; tp2 <- what goes here?
> 

I believe this is the type Richard wishes to declare in Mercury syntax.

:- type nat
    --->    zero        % 0
    ;       tp1(nat)    % 2x+1
    ;       tp2(nat)    % 2x+2
        
Pete
--------------------------------------------------------------------------
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