From: Maxence Guesdon <Maxence.Guesdon@inria.fr>
To: caml-list@inria.fr
Subject: [Caml-list] Strange type inference error
Date: Fri, 23 Jan 2015 15:43:23 +0100 [thread overview]
Message-ID: <20150123154323.1fc8e7d8@alcazar2> (raw)
Hello,
I encountered a strange typing problem and reduced it to the following
code example:
====[t.ml]====
let mk_env () = None
let list_of_string (s: string) = [s]
let apply : 'a -> 'a option -> string list -> 'a * string list =
fun acc env l -> (acc, ["hello"])
let f =
let tmpl = ["coucou"] in
fun ?(env=mk_env()) ->
fun ~x ->
fun () -> apply () env tmpl
let g =
let tmpl = list_of_string "coucou" in
fun ?(env=mk_env()) ->
fun ~x ->
fun () -> apply () env tmpl
====
Note that f and g only differ on the way tmpl is defined.
When I compile this file with ocaml 4.02.1, I get the following error:
File "t.ml", line 14, characters 3-119:
Error: The type of this expression,
?env:unit option -> x:'_a -> unit -> unit * string list,
contains type variables that cannot be generalized
Am I missing something or should I file a bug report ?
Regards,
Maxence
next reply other threads:[~2015-01-23 14:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-23 14:43 Maxence Guesdon [this message]
2015-01-23 15:04 ` Arnaud Spiwack
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=20150123154323.1fc8e7d8@alcazar2 \
--to=maxence.guesdon@inria.fr \
--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