Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Unbound type variables
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-09-13 (17:15)
From: Patrick M Doane <patrick@w...>
Subject: [Caml-list] Unbound type variables
While writing code today, I came across an annoying problem with using
polymorphic variants and objects. The basic code fragment is this:

class c = object
  method m x =
    match x with
      | `A -> ()
      | `B -> ()
      | `C -> ()

which produces an error:

The method m has type
  [< `A | `B | `C] -> unit
where .. is unbound

Now, there is a simple solution to the problem:

  type t = [ `A | `B | `C]


  match (x:t) with

but one of the benefits of using polymorphic variants is that I can
usually avoid such redundant declarations.

I'm also suprised by the inferred type, since the polymorphism
just causing a failure and there isn't anyway I'm aware of to be able to
bind that row variable to the type of the class.  Would it be better to
type the expression differently from within an object context?

Any other ways I can improve what I'm doing?


Bug reports:  FAQ:
To unsubscribe, mail  Archives: