From: Peng Zang <peng.zang@gmail.com>
To: caml-list@yquem.inria.fr
Cc: Samuel Mimram <samuel.mimram@ens-lyon.org>
Subject: Re: [Caml-list] Objects and variants
Date: Fri, 6 Mar 2009 11:10:10 -0500 [thread overview]
Message-ID: <200903061110.12728.peng.zang@gmail.com> (raw)
In-Reply-To: <49B147F7.4090303@ens-lyon.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
You're looking for a polymorphic method:
class a = object
method f : 'a. ([>] as 'a) -> unit = fun _ -> ()
end
Peng
On Friday 06 March 2009 10:57:43 am Samuel Mimram wrote:
> Hi,
>
> When I try to compile the following code:
>
> class a =
> object
> method f (x:[>]) = ()
> end
>
> I get the following error:
>
> Error: Some type variables are unbound in this type:
> class a : object method f : [> ] -> unit end
> The method f has type ([> ] as 'a) -> unit where 'a is unbound
>
> Is the binding of [>] to 'a really necessary here? In particular it is
> not mentioned in the inferred type...
>
> Of course I can parametrize the class over 'a as
>
> class ['a] a =
> object
> method f (x:[>] as 'a) = ()
> end
>
> which now has type
>
> class ['a] a : object constraint 'a = [> ] method f : 'a -> unit end
>
> But this seems rather cumbersome. Is there a way to handle this without
> mentioning 'a?
>
> Thanks!
>
> Cheers,
>
> Samuel.
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
iD8DBQFJsUrkfIRcEFL/JewRAqJ3AKC7Dl6+a97yrs1PKPLDEzL5c3vbVACcDdrJ
16BPB2/+ddTB4OHB/4zQ+LA=
=ltZH
-----END PGP SIGNATURE-----
prev parent reply other threads:[~2009-03-06 16:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-06 15:57 Samuel Mimram
2009-03-06 16:10 ` Peng Zang [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=200903061110.12728.peng.zang@gmail.com \
--to=peng.zang@gmail.com \
--cc=caml-list@yquem.inria.fr \
--cc=samuel.mimram@ens-lyon.org \
/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