Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
RE: Dichotomy between functions and type constructors?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2000-02-21 (18:03)
From: Don Syme <dsyme@m...>
Subject: RE: Dichotomy between functions and type constructors?
I believe it's got something to do with cross module optimization.  However,
I've always wondered why the restriction is not lifted at least inside the
module where the constructor is declared.


-----Original Message-----
From: David McClain []
Sent: 21 February 2000 17:09
Subject: Dichotomy between functions and type constructors?

I am curious about the apparent dichotomy between normal functions and type
constructors, and why this disparity exists?

Say I have a type

type thing =
   T1 of int * float
| ....

I can create such a type as T1(5, 3.14) but I cannot create such a type on a
tuple result of a function call:

let doit x = (x, float_of_int x)

let myT1 = T1(doit x)

This gives rise to a type checking error wherein the constructor T1 demands
two arguments, instead of demanding a tuple of two elements.

SML does not appear to impose this same requirement on the programmer, so
what is the origin of the OCaml requirement?


David McClain, Sr. Scientist
Raytheon Systems Co.
Tucson, AZ