caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: caml-list <caml-list@inria.fr>
Subject: [Caml-list] Polymorphic variants problem
Date: Sun, 03 Sep 2006 10:48:29 +1000	[thread overview]
Message-ID: <1157244509.12057.29.camel@rosella.wigram> (raw)
In-Reply-To: <1157138993.22787.34.camel@rosella.wigram>

On Sat, 2006-09-02 at 05:29 +1000, skaller wrote:

I wrote this:

> (b) annotate function arguments and returns -- if not
>    all of them, focus on the top level ones: it's necessary
>    for the mli file anyhow.

Now, I just tried to use my super term union, but I ran
into a problem. It looks like a fault in type inference,
something like this:

let f (x:[`A|`B]) = ..
let g (x:[`A]) = ..
..
fun x ->
   f x;
   g x;
   ..

I get a type error on g x, Ocaml is telling me x has type
[`A|`B] but is used in a context requiring a type [`A].

Of course the problem is evident: the actual type is
indeed [`A], but the first application is deducing it
to [`A|`B]. The question is: why isn't the second application
narrowing it using an intersection? [Why isn't the initial
deduction simply a bound which is further constrained?)

The actual message I got was:

File "./lpsrc/flx_lookup.ipk", line 968, characters 19-21:
This expression has type Flx_print.felix_term_t 
but is here used with type Flx_ast.typecode_t

A typecode is-a term.

-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net


  parent reply	other threads:[~2006-09-03  0:48 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-01 17:31 Polymorphic variants question David Allsopp
2006-09-01 18:33 ` Chris King
2006-09-01 19:00   ` [Caml-list] " skaller
2006-09-01 19:57     ` David Allsopp
2006-09-01 20:40       ` Jacques Carette
2006-09-01 18:40 ` [Caml-list] " Olivier Andrieu
2006-09-01 19:26 ` Jon Harrop
2006-09-01 19:29 ` skaller
2006-09-01 20:49   ` Andres Varon
2006-09-02 11:16     ` Jacques Garrigue
2006-09-03  1:22       ` Andres Varon
2006-09-03  9:08         ` Jacques Garrigue
2006-09-03 15:00           ` Andres Varon
2006-09-03 23:18             ` Jacques Garrigue
2006-09-03  0:48   ` skaller [this message]
2006-09-03  1:12     ` [Caml-list] Polymorphic variants problem Andres Varon

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=1157244509.12057.29.camel@rosella.wigram \
    --to=skaller@users.sourceforge.net \
    --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).