From: "Jérémie Dimino" <jeremie@dimino.org>
To: Michael <micha-1@fantasymail.de>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] storing object in record
Date: Wed, 08 Apr 2009 13:36:39 +0200 [thread overview]
Message-ID: <1239190599.6630.75.camel@localhost.localdomain> (raw)
In-Reply-To: <200904081229.03099.micha-1@fantasymail.de>
Le mercredi 08 avril 2009 à 12:29 +0200, Michael a écrit :
> > There is no value of type: forall 'a. #baseclass as 'a.
>
> is this similar? :
>
> type 'a xx = 'a constraint 'a = < asBase: baseObject; .. > ;;
>
> (why does: type 'a xx = < asBase: baseObject; ..> as 'a not work instead? )
No, [type 'a xx = 'a constraint 'a = < asBase: baseObject; .. >] just
means that ['a] must match [< asBase : baseObject; .. >]. Actually
constraints are just inlined:
# type 'a t = 'a constraint 'a = _ * _;;
type 'a t = 'a constraint 'a = 'b * 'c
# let f (x : 'a t) = ();;
val f : ('a * 'b) t -> unit = <fun>
If you write [type 'a xx = < asBase: baseObject; ..>] (with or without
[as 'a]), then you have an unbound variable in the type definition (the
[..]).
> type 'a r = { state: 'a xx };;
>
> gives:
> type 'a r = { state : 'a xx; } constraint 'a = < asBase : baseObject; .. >
>
>
> so the record holds objects with an asBase method and more, isn't this the
> same as #baseObject?
[#baseObject] is an abbreviation for [< asBase : baseObject; .. >].
Jérémie
prev parent reply other threads:[~2009-04-08 11:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-08 7:36 Michael
2009-04-08 7:54 ` [Caml-list] " Jérémie Dimino
2009-04-08 10:29 ` Michael
2009-04-08 11:36 ` Jérémie Dimino [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=1239190599.6630.75.camel@localhost.localdomain \
--to=jeremie@dimino.org \
--cc=caml-list@yquem.inria.fr \
--cc=micha-1@fantasymail.de \
/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