[mercury-users] undiscriminated unions

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Jan 10 23:29:07 AEDT 2002


On 10-Jan-2002, Dave Slutzkin <dave_slutzkin at yahoo.com> wrote:
> Undiscriminated union types - there's an example of
> them in the language reference (I think it's
> employee), but the compiler says 'not implemented'.

The employee example,

    :- type employee
             --->    employee(
                            name        :: string,
                            age         :: int,
                            department  :: string
                     ).

is NOT an example of undiscriminated union types.  It is an example of a
discriminated union type with only one alternative.  Such types are fully
supported by the current Mercury implementation.

An undiscriminated union would be something like this,

	:- type num = int ; float.

meaning a type whose set of values is the union of values of type int and the
values of type float.  This is not currently supported, and may never be
supported, because there are other ways of achieving the same effect,
such as using discriminated unions:

	:- type num ---> i(int) ; f(float).

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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