Version française
Home     About     Download     Resources     Contact us    
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) =
object 
  method str_len (l: string list) = len l
  method int_len (l: int list)    = len l
end

$ 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

-- 
Chris Stork   <>  Support eff.org!  <>   http://www.ics.uci.edu/~cstork/
OpenPGP fingerprint:  B08B 602C C806 C492 D069  021E 41F3 8C8D 50F9 CA2F