caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "David McClain" <dmcclain@azstarnet.com>
To: <caml-list@inria.fr>
Subject: Dichotomy between functions and type constructors?
Date: Fri, 18 Feb 2000 13:47:28 -0700	[thread overview]
Message-ID: <000501bf7a51$60490100$250148bf@vega> (raw)

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




             reply	other threads:[~2000-02-21 17:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-02-18 20:47 David McClain [this message]
2000-02-21 19:31 ` Markus Mottl
2000-02-25 14:28 ` Xavier Leroy
2000-02-21 18:02 Don Syme

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='000501bf7a51$60490100$250148bf@vega' \
    --to=dmcclain@azstarnet.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).