caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gerd Stolpmann <info@gerd-stolpmann.de>
To: Christian Stork <cstork@ics.uci.edu>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Monomorphism restriction in classes
Date: Fri, 17 Feb 2006 22:53:44 +0100	[thread overview]
Message-ID: <1140213224.10403.33.camel@localhost.localdomain> (raw)
In-Reply-To: <20060217210920.GA27593@anthony.ics.uci.edu>

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
------------------------------------------------------------


      reply	other threads:[~2006-02-17 21:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-17 21:09 Christian Stork
2006-02-17 21:53 ` Gerd Stolpmann [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1140213224.10403.33.camel@localhost.localdomain \
    --to=info@gerd-stolpmann.de \
    --cc=caml-list@inria.fr \
    --cc=cstork@ics.uci.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).