From: Leo White <leo@lpw25.net>
To: Gregory Malecha <gmalecha@gmail.com>
Cc: caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] "Type constructor b would escape its scope"
Date: Sun, 27 Mar 2016 08:04:42 +0100 [thread overview]
Message-ID: <86d1qgqu45.fsf@lpw25.net> (raw)
In-Reply-To: <CAGraiHLc4w5s7+AYbkHfWKJ7agdrD4Zxuc5ptRT_hsTxjyUjbQ@mail.gmail.com> (Gregory Malecha's message of "Sat, 26 Mar 2016 23:19:34 -0700")
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
next prev parent reply other threads:[~2016-03-27 7:04 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 [this message]
2016-03-27 18:52 ` Gregory Malecha
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=86d1qgqu45.fsf@lpw25.net \
--to=leo@lpw25.net \
--cc=caml-list@inria.fr \
--cc=gmalecha@gmail.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