caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gregory Malecha <gmalecha@gmail.com>
To: Leo White <leo@lpw25.net>
Cc: caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] "Type constructor b would escape its scope"
Date: Sun, 27 Mar 2016 11:52:15 -0700	[thread overview]
Message-ID: <CAGraiHJ=j_YtaKttyrZaXunc=1xuFBGZw20rOv1s+sAHwxqsOg@mail.gmail.com> (raw)
In-Reply-To: <86d1qgqu45.fsf@lpw25.net>

[-- Attachment #1: Type: text/plain, Size: 1509 bytes --]

Thanks, Leo --

This is exactly what I needed to know. I thought that the (type a)
annotation was forcing the function to be polymorphic. For future
reference, is there any way to write the annotation (that forces the
function to be polymorphic) without having to write explicit 'fun's?

Thanks.

On Sun, Mar 27, 2016 at 12:04 AM, Leo White <leo@lpw25.net> wrote:

> This is a guess since you didn't include the definition of
> stream_declarations, but I suspect that:
>
> > (* I have the following function, which seems to type check *)
> > let stream_declarations (type a)
> > : (internal_result,a) result_stream = ...
>
> is not polymorphic. The `(type a)` annotation ensures that `a` is
> abstract in the body of `stream_declarations` but does not enforce
> that the result is polymorphic -- in particular I suspect that you
> are running up against the value restriction. An easy way to check
> would be to change the definition to:
>
>   let stream_declarations : 'a. (internal_result,'a) result_stream =
>   ...
>
> or
>
>   let stream_declarations : type a. (internal_result,a) result_stream =
>   ...
>
> both of which enforce polymorphism, and so will give an error if your
> definition is actually monomorphic.
>
> If `stream_declarations` does have the monomorphic type
> `(internal_result, '_a) result_stream` then any attempt to use it as
> `(internal_result, b) result_stream` would cause `b` to be unified with
> `'_a` and thus escape it's scope.
>
> Regards,
>
> Leo
>



-- 
gregory malecha

[-- Attachment #2: Type: text/html, Size: 2082 bytes --]

  reply	other threads:[~2016-03-27 18:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-27  6:19 Gregory Malecha
2016-03-27  7:04 ` Leo White
2016-03-27 18:52   ` Gregory Malecha [this message]
2016-03-28  1:12     ` Jacques Garrigue
2016-03-28  4:20       ` Gregory Malecha
2016-03-28  8:07         ` Gabriel Scherer
2016-03-28 15:35           ` Gregory Malecha
2016-03-28 19:20           ` Arnaud Spiwack
2016-03-28 20:51             ` Leo White
2016-03-28 21:00             ` Gerd Stolpmann

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='CAGraiHJ=j_YtaKttyrZaXunc=1xuFBGZw20rOv1s+sAHwxqsOg@mail.gmail.com' \
    --to=gmalecha@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=leo@lpw25.net \
    /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).