caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Matej Kosik <5764c029b688c1c0d24a2e97cd764f@gmail.com>
To: OCaml <caml-list@inria.fr>
Subject: Re: [Caml-list] strange typechecking result
Date: Fri, 22 Feb 2013 20:14:35 +0000	[thread overview]
Message-ID: <5127D1AB.6090204@gmail.com> (raw)
In-Reply-To: <Prayer.1.3.5.1302221833330.26859@hermes-1.csi.cam.ac.uk>

On 22/02/13 18:33, Leo White wrote:
>>
>
> I think that by default recursive uses of a function are monomorphic.
> You can fix this with an explicit polymorphic annotation:
>
> let rec f1: 'a. 'a -> unit = fun _ -> ()
> and f2 r1 = f1 r1.l1
> and f3 r2 = f1 r2.l2;;
>
> Regards,
>
> Leo
>

Yuri, Leo, thanks.

Now I see that there is even simpler program, that demonstrates the problem:

   let rec f1 _ =
     ()

   and f2 (value:int) =
     f1 value

   and f3 (value:char) =
     f1 value

The typechecker rejects it for similar reasons.

   File "test.ml", line 8, characters 5-10:
   Error: This expression has type char but an expression
          was expected of type int.

That's quite strange.

I would like to ask:

- Where is that restriction explained?
   (I've searched Ocaml reference manual for "monomorphic" but nothing
    relevant seemed to come up)

- Where are things like:

      'a. 'a -> unit

   described?

   I've already seen it in some document, but now I fail
   to find it again.

  reply	other threads:[~2013-02-22 20:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-22 17:50 Matej Kosik
2013-02-22 18:33 ` Leo White
2013-02-22 20:14   ` Matej Kosik [this message]
2013-02-22 21:06     ` Leo White
2013-02-22 23:09       ` Jeff Meister

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=5127D1AB.6090204@gmail.com \
    --to=5764c029b688c1c0d24a2e97cd764f@gmail.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).