caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Fermin Reig <fermin.reig@cs.nott.ac.uk>
To: yminsky@cs.cornell.edu
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] When is a function polymorphic?
Date: Thu, 31 Mar 2005 13:48:14 +0100	[thread overview]
Message-ID: <1112273293.17931.66.camel@kiwi> (raw)
In-Reply-To: <891bd33905033104045705be7a@mail.gmail.com>

On Thu, 2005-03-31 at 13:04, Yaron Minsky wrote:
> On Thu, 31 Mar 2005 17:32:23 +0900 (JST), Jacques Garrigue
> > Is it so difficult to make the extra constructors explicit?
> 
> I'd say there are two issues.  The first is that it really can be a
> pain for large variant types, particularly when the contents of those
> types are changing during development, and you don't want the function
> in question to depend on anything other than the particular variants
> being modified.
> [...]

In my code, I try to avoid catchall '_' and 'x' patterns when possible.
I end up with long 'or' patterns, such as

| (A _ | B _ | C _ | ...) -> ...

This style, while more verbose, has one advantage: if I later add a new
constructor to my type, the exhaustiveness analysis warns me of all
places where I should check. (In fact, this is most useful during
development, since that's when type definitions change.)

Regarding the typing of

# function Some x -> Some () | None -> None;;
# function Some x -> Some () | x -> x;;

both Haskell and SML do the same as Ocaml, but, unlike Ocaml, neither
gives a polymorphic type when using an 'as x' pattern.

Fermin



This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.


  reply	other threads:[~2005-03-31 12:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-30 22:31 Yaron Minsky
2005-03-31  0:37 ` [Caml-list] " Jacques Garrigue
2005-03-31  0:51   ` Yaron Minsky
2005-03-31  1:15     ` Eric Cooper
2005-03-31  1:26     ` Martin Jambon
2005-03-31  2:42     ` Jacques Garrigue
2005-03-31  4:04       ` Yaron Minsky
2005-03-31  8:32         ` Jacques Garrigue
2005-03-31 12:04           ` Yaron Minsky
2005-03-31 12:48             ` Fermin Reig [this message]
2005-03-31 12:16           ` Jon Harrop
2005-04-01 16:26           ` Luc Maranget

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=1112273293.17931.66.camel@kiwi \
    --to=fermin.reig@cs.nott.ac.uk \
    --cc=caml-list@inria.fr \
    --cc=yminsky@cs.cornell.edu \
    /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).