[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Olivier Andrieu <andrieu@i...> |
| Subject: | Re: [Caml-list] Unbound type variables |
Patrick M Doane [Thursday 13 September 2001] :
>
> 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 -> ()
> end
>
> which produces an error:
>
> The method m has type
> [< `A | `B | `C] -> unit
> where .. is unbound
> ... there isn't anyway I'm aware of to be able to
> bind that row variable to the type of the class.
yes you can (if I understand you correctly) :
class ['a] c = object
method m : 'a -> unit = function
| `A -> ()
| `B -> ()
| `C -> ()
end
and you get
class ['a] c :
object
constraint 'a = [< `A | `B | `C]
method m : 'a -> unit
end
--
Olivier
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr