English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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: 2006-02-17 (21:09)
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