[mercury-users] Restricted types with inst declarations? ELL type/inst usage?

Ian MacLarty maclarty at cs.mu.OZ.AU
Wed Feb 22 07:49:55 AEDT 2006


On 21 Feb 2006, at 19:56, doug.auclair at logicaltypes.com wrote:

> Dear all,
>
> Hi!  I wish to create a type bound to a subset of one of the 
> previously defined types.  Specifically, I wish to define the type 
> 'bit' and restrict it, solely, to the two ints '1' and '0'.  I've got 
> only so far as:
>
> :- type bit == int.
>
> but when I try to restrict the type, I get compile errors:
>
> % :- inst bit == bound(1; 0).   % WRONG!
>

The following will work:

:- inst bit
         --->    0
         ;       1.

But why don't you just do:

:- type bit
	--->	one
	;		zero.

I think that would make your life simpler.

Ian.

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