Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Keiko Nakata <keiko@kurims.kyoto-u.ac.jp>
To: Andrej.Bauer@andrej.com
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] a function for polymorphic and monomorphic objects
Date: Thu, 08 Nov 2007 21:09:39 +0900 (JST)	[thread overview]
Message-ID: <20071108.210939.68538729.keiko@kurims.kyoto-u.ac.jp> (raw)
In-Reply-To: <4732E97B.9080805@fmf.uni-lj.si>

> In your case you got it wrong when you quantified 'a in the object p.

> # let p = object method map =  fun f -> List.map f [1;2;3] end;;
> val p : < map : (int -> 'a) -> 'a list > = <obj>

Perhaps I oversimplified my example.
Indeed I want to make p a function like

let p1 l = object 
  method map : 'a.(int -> 'a) -> 'a list =  fun f -> List.map f l
end;;

let o1 = p1 [1;2;3];;
- val o1 : < map : 'a. (int -> 'a) -> 'a list > = <obj>

Then I need type annotations

let p2 l = object 
  method map =  fun f -> List.map f l
end;;
let o2 = p2 [1;2;3];;
- val o2 : < map : (int -> '_a) -> '_a list > = <obj>


With best,
keiko


  reply	other threads:[~2007-11-08 12:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-08  9:05 Keiko Nakata
2007-11-08 10:48 ` [Caml-list] " Andrej Bauer
2007-11-08 12:09   ` Keiko Nakata [this message]
2007-11-09  1:35     ` Peng Zang
2007-11-09  2:50 ` Jacques Garrigue

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=20071108.210939.68538729.keiko@kurims.kyoto-u.ac.jp \
    --to=keiko@kurims.kyoto-u.ac.jp \
    --cc=Andrej.Bauer@andrej.com \
    --cc=caml-list@inria.fr \
    /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