<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2006/02/c3c8a28adc8b56f31cc56338bf3e28d2"
  from="Gerd Stolpmann &lt;info@g...&gt;"
  author="Gerd Stolpmann"
  date="2006-02-17T21:53:54"
  subject="Re: [Caml-list] Monomorphism restriction in classes"
  prev="2006/02/cd3875acc017c9aaeafad61ed359e833"
  next="2006/02/f8740e1d5e810115545d1dceacaa7b1d"
  prev-in-thread="2006/02/cd3875acc017c9aaeafad61ed359e833"
  prev-thread="2006/02/726bafa7a07b271413529afdb261744e"
  next-thread="2006/02/f8740e1d5e810115545d1dceacaa7b1d"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="Monomorphism restriction in classes">
<msg 
  url="2006/02/cd3875acc017c9aaeafad61ed359e833"
  from="Christian Stork &lt;cstork@i...&gt;"
  author="Christian Stork"
  date="2006-02-17T21:09:10"
  subject="Monomorphism restriction in classes">
<msg 
  url="2006/02/c3c8a28adc8b56f31cc56338bf3e28d2"
  from="Gerd Stolpmann &lt;info@g...&gt;"
  author="Gerd Stolpmann"
  date="2006-02-17T21:53:54"
  subject="Re: [Caml-list] Monomorphism restriction in classes">
</msg>
</msg>
</thread>

<contents>
Am Freitag, den 17.02.2006, 13:09 -0800 schrieb Christian Stork:
&gt; So, what's the best work-around for this problem?
&gt; 
&gt; class c (len : 'a list -&gt; int) =
&gt; object 
&gt;   method str_len (l: string list) = len l
&gt;   method int_len (l: int list)    = len l
&gt; end
&gt; 

type len_t = { len : 'a . 'a list -&gt; 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 -&gt; int) = ...

Gerd

&gt; $ ocamlc monoRestForClasses.ml 
&gt; File "monoRestForClasses.ml", line 7, characters 40-41:
&gt; This expression has type int list but is here used with type string list
&gt;  
&gt; Thanks,
&gt; Chris
&gt; 
-- 
------------------------------------------------------------
Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany 
gerd@gerd-stolpmann.de          http://www.gerd-stolpmann.de
Phone: +49-6151-153855                  Fax: +49-6151-997714
------------------------------------------------------------

</contents>

</message>

