[
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: | Gerd Stolpmann <info@g...> |
| Subject: | Re: [Caml-list] Monomorphism restriction in classes |
Am Freitag, den 17.02.2006, 13:09 -0800 schrieb Christian Stork:
> So, what's the best work-around for this problem?
>
> class c (len : 'a list -> int) =
> object
> method str_len (l: string list) = len l
> method int_len (l: int list) = len l
> end
>
type len_t = { len : 'a . 'a list -> int}
class c (len :len_t) =
object
method str_len (l:string list) = len.len l
method int_len (l: int list) = len.len l
end
I don't know why the 'a.t syntax is only allowed for records and
methods, and why one cannot say
class c (len : 'a . 'a list -> int) = ...
Gerd
> $ ocamlc monoRestForClasses.ml
> File "monoRestForClasses.ml", line 7, characters 40-41:
> This expression has type int list but is here used with type string list
>
> Thanks,
> Chris
>
--
------------------------------------------------------------
Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany
gerd@gerd-stolpmann.de http://www.gerd-stolpmann.de
Phone: +49-6151-153855 Fax: +49-6151-997714
------------------------------------------------------------