Browse thread
a function for polymorphic and monomorphic objects
-
Keiko Nakata
-
Andrej Bauer
- Keiko Nakata
- Jacques Garrigue
-
Andrej Bauer
[
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: | Keiko Nakata <keiko@k...> |
| Subject: | Re: [Caml-list] a function for polymorphic and monomorphic objects |
> In your case you got it wrong when you quantified 'a in the object p. > # let p = object method map = fun f -> List.map f [1;2;3] end;; > val p : < map : (int -> 'a) -> 'a list > = <obj> Perhaps I oversimplified my example. Indeed I want to make p a function like let p1 l = object method map : 'a.(int -> 'a) -> 'a list = fun f -> List.map f l end;; let o1 = p1 [1;2;3];; - val o1 : < map : 'a. (int -> 'a) -> 'a list > = <obj> Then I need type annotations let p2 l = object method map = fun f -> List.map f l end;; let o2 = p2 [1;2;3];; - val o2 : < map : (int -> '_a) -> '_a list > = <obj> With best, keiko