Constructed types

From: Chris Keane (Chris.Keane@comlab.ox.ac.uk)
Date: Wed Jan 20 1999 - 11:42:18 MET


Message-Id: <199901201042.KAA01535@msc2.comlab>
To: caml-list@inria.fr
Subject: Constructed types
Date: Wed, 20 Jan 1999 10:42:18 +0000
From: Chris Keane <Chris.Keane@comlab.ox.ac.uk>

If this works as it should:

> Objective Caml version 2.00
>
> # type foo =
> Bar of int * int;;
> type foo = | Bar of int * int
> # let myfun x =
> let (m,n) = if x = 0 then (0,0) else (1,1) in
> Bar (m,n);;
> val myfun : int -> foo = <fun>

then why doesn't this?

> # let myfun2 x =
> let m = if x = 0 then (0,0) else (1,1) in
> Bar m;;
> The constructor Bar expects 2 argument(s),
> but is here applied to 1 argument(s)

or even this?

> # let myfun3 x =
> Bar (if x = 0 then (0,0) else (1,1));;
> The constructor Bar expects 2 argument(s),
> but is here applied to 1 argument(s)

Thanks,
Chris.

------------------------------------------------------------------- ><> ---
    Hardware Compilation Group, Oxford University Computing Laboratory,
            Wolfson Building, Parks Road, Oxford, OX1 3QD, U.K.
    tel: +44 (1865) (2)73865 e-mail: Chris.Keane@comlab.ox.ac.uk
            http://www.comlab.ox.ac.uk/oucl/users/chris.keane/



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:18 MET