Version française
Home     About     Download     Resources     Contact us    
Browse thread
Polymorphic variants question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: skaller <skaller@u...>
Subject: [Caml-list] Polymorphic variants problem
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