Dichotomy between functions and type constructors?

From: David McClain (dmcclain@azstarnet.com)
Date: Fri Feb 18 2000 - 21:47:28 MET

  • Next message: Jacques Garrigue: "Re: variant filtering"

    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



    This archive was generated by hypermail 2b29 : Mon Feb 21 2000 - 18:10:41 MET