Version française
Home     About     Download     Resources     Contact us    
Browse thread
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: -- (:)
From: David McClain <dmcclain@a...>
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?

TIA,

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