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
Monomorphism restriction in classes
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Christian Stork <cstork@i...>
Subject: Monomorphism restriction in classes
So, what's the best work-around for this problem?

class c (len : 'a list -> int) =
  method str_len (l: string list) = len l
  method int_len (l: int list)    = len l

$ ocamlc 
File "", line 7, characters 40-41:
This expression has type int list but is here used with type string list

Chris Stork   <>  Support!  <>
OpenPGP fingerprint:  B08B 602C C806 C492 D069  021E 41F3 8C8D 50F9 CA2F