caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: jon@ffconsultancy.com
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Type error
Date: Sat, 02 Apr 2005 16:50:09 +0900 (JST)	[thread overview]
Message-ID: <20050402.165009.129498726.garrigue@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <200504020229.33295.jon@ffconsultancy.com>

From: Jon Harrop <jon@ffconsultancy.com>

> I've got a type error:
> 
> This type of expression, <height:int; width:int; _..> -> unit, contains type 
> variables that cannot be generalized
> 
> which appears with the form:
> 
> let f =
>   let t = ref None in
>   fun data -> ...
> 
> but not in the unnested form:
> 
> let t = ref None
> 
> let f =
>   fun data -> ...
> 
> Is that supposed to happen? I thought those two forms were exactly
> equivalent.  

They are not.
The criterion to decide whether to generalize type variables in a
definition is whether it is syntactically a "value" or not.
Since [ref None] is not a value, your first definition ends up not
being a value, and cannot be generalized.
The second one is ok, because probably t is later constrained to have
a specific type (not containing type variables) and f is now a "value"
and can be properly generalized.
Note also that this error message does not occur if you provide an
interface for your module. But you may in place have a message about a
type not being included in another, if you really expected the
function to be polymorphic.

Jacques Garrigue


  reply	other threads:[~2005-04-02  7:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-02  1:29 Jon Harrop
2005-04-02  7:50 ` Jacques Garrigue [this message]
2006-10-15  3:29 Denis Bueno
2006-10-15  3:40 ` [Caml-list] " Jonathan Roewen
2006-10-15  3:48 ` skaller
2006-10-15  3:54 ` Jonathan Roewen
2006-10-15 11:26 ` Etienne Miret
2006-10-15 23:37 ` Jacques Garrigue
2008-03-23 22:01 type error Jacques Le Normand
2008-03-23 22:19 ` [Caml-list] " Martin Jambon
2008-04-01  2:27 Jacques Le Normand
2008-04-01  2:42 ` [Caml-list] " Jacques Garrigue

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=20050402.165009.129498726.garrigue@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=caml-list@yquem.inria.fr \
    --cc=jon@ffconsultancy.com \
    /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).