From: Goswin von Brederlow <goswin-v-b@web.de>
To: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
Cc: goswin-v-b@web.de, caml-list@inria.fr
Subject: Re: [Caml-list] Subtyping
Date: Wed, 08 Apr 2009 07:16:41 +0200 [thread overview]
Message-ID: <87ocv7ybba.fsf@frosties.localdomain> (raw)
In-Reply-To: <20090408.103501.38023937.garrigue@math.nagoya-u.ac.jp> (Jacques Garrigue's message of "Wed, 08 Apr 2009 10:35:01 +0900 (JST)")
Jacques Garrigue <garrigue@math.nagoya-u.ac.jp> writes:
> type 'a base = {x : 'a; fn : 'a -> unit}
> type 'b base_op = {bop: 'a. 'a base -> 'b}
> type base_wrapper = {base: 'b. 'b base_op -> 'b}
>
> let l =
> let a = {x = 1; fn = print_int}
> and b = {x = 1.2; fn = print_float} in
> [{base = fun x -> x.bop a}; {base = fun x -> x.bop b}]
>
> List.iter (fun w -> w.base {bop = fun r -> r.fn r.x}) l
>
> As you can see, the result is rather verbose, but this works.
> Fortunately, closure and objects are usually enough...
>
> Jacques Garrigue
That is exactly what I ment. I knew closures could have "'a. ..."
types but I didn't think of encoding the record and the method to
call both as closures.
MfG
Goswin
prev parent reply other threads:[~2009-04-08 5:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-07 5:48 Subtyping Goswin von Brederlow
2009-04-07 7:41 ` [Caml-list] Subtyping David MENTRE
2009-04-07 13:39 ` Peng Zang
2009-04-07 21:33 ` Goswin von Brederlow
2009-04-07 21:32 ` Goswin von Brederlow
2009-04-08 0:38 ` Goswin von Brederlow
2009-04-08 1:35 ` Jacques Garrigue
2009-04-08 2:43 ` Jacques Garrigue
2009-04-08 5:16 ` Goswin von Brederlow [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=87ocv7ybba.fsf@frosties.localdomain \
--to=goswin-v-b@web.de \
--cc=caml-list@inria.fr \
--cc=garrigue@math.nagoya-u.ac.jp \
/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