caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] tpyping question
@ 2003-08-11  1:13 skaller
  2003-08-11  2:46 ` Jacques Garrigue
  2003-08-11  2:51 ` Oleg Trott
  0 siblings, 2 replies; 12+ messages in thread
From: skaller @ 2003-08-11  1:13 UTC (permalink / raw)
  To: caml-list

type x = [`A | `B of int | `V of float];;
let g (a:x) = a;;
let f a = match a with
| `A -> g a
(* | `B _ *) | _ -> g a;;

Compiles fine, but gives an error if the comments are
removed.

File "xx.ml", line 4, characters 10-11:
This expression has type [< `A | `B of 'a ] but is here used with type
  x = [ `A | `B of int | `V of float ]
The first variant type does not allow tag(s) `V

I can fix this with a coercion/annotation:

| (`A:x) -> g a

but that's a bit messy. Of course an annotation on the
argument doesn't work (since such annotations are only
consulted *after* the body type is infered).

Is there a better way to do this?


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2003-08-12  4:25 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-11  1:13 [Caml-list] tpyping question skaller
2003-08-11  2:46 ` Jacques Garrigue
2003-08-11  4:30   ` skaller
2003-08-12  3:24   ` Jacques Garrigue
2003-08-11  2:51 ` Oleg Trott
2003-08-11  4:39   ` skaller
2003-08-11  5:18     ` Karl Zilles
2003-08-11 18:13       ` Karl Zilles
2003-08-11 18:16       ` skaller
2003-08-11 19:02         ` Remi Vanicat
2003-08-12  4:25           ` skaller
2003-08-11 19:02         ` Tiphaine Turpin

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).