[mercury-users] natural numbers

Robert Bossy bossy at ccr.jussieu.fr
Tue Jul 24 19:21:50 AEST 2001


[ Tue, 24 Jul 2001 18:24:08 +1000 ] Robert Colvin <robert at svrc.uq.edu.au> -> mercury-users at cs.mu.OZ.AU

> Hi, I wanted to know what is/would be the usual way to define the natural
> numbers using successor notation in Mercury.  Preferably I would use this:
> 
> :- type nat ---> 0; s(nat).
> 
> but I get the error:
> 
> mercTranslate.m:471: Error: invalid RHS of type definition: 0 ; s(nat).
> 
> which I assume is from the use of `0'.  I will probably use eg. `e' in place of
> 0, unless there is something I'm missing...?

That's it.
Constructors must be valid atoms i.e. a word begining with a lowercase alphabetic character.

:- type nat ---> zero; s(nat).


However you can use quotes if you insist having the 0 constructor:

:- type nat ---> '0'; s(nat).

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