From: Keith Wansbrough <Keith.Wansbrough@cl.cam.ac.uk>
To: Remi Vanicat <remi.vanicat@laposte.net>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Documentation error - #myvariant
Date: Thu, 29 Apr 2004 14:54:56 +0100 [thread overview]
Message-ID: <E1BJC08-0007xz-00@mta1.cl.cam.ac.uk> (raw)
In-Reply-To: Your message of "Thu, 29 Apr 2004 14:40:37 +0200." <8765bjvtx6.dlv@vanicat.homelinux.org>
Rémi Vanicat writes:
> The documentation is accurate.
I think the documentation is unclear, and should be clarified. All
the OCaml manual says is:
"if you have defined type myvariant = [`Tag1 int | `Tag2 bool], then
the pattern #myvariant is equivalent to writing (`Tag1(_ : int) |
`Tag2(_ : bool))."
This says nothing about how recursive types are treated when
#myvariant occurs in a supertype context. Since this is surely a
common use of polymorphic variants, it should at least say "the g1 / g
example is misleading, as this #myvariant style won't work in most
useful cases".
> In fact, your code will do what you want if you don't define your type
> as recursive but as polymorphic :
OK - that type trick corresponds to the term trick already explained
in the manual, with passing the recursive function explicitly. Shades
of Steele, 1994, _Building Interpreters by Composing Monads_(!).
Thanks..
--KW 8-)
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next prev parent reply other threads:[~2004-04-29 13:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-29 11:18 Keith Wansbrough
2004-04-29 12:40 ` Remi Vanicat
2004-04-29 13:54 ` Keith Wansbrough [this message]
2004-04-29 18:09 ` skaller
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=E1BJC08-0007xz-00@mta1.cl.cam.ac.uk \
--to=keith.wansbrough@cl.cam.ac.uk \
--cc=caml-list@inria.fr \
--cc=remi.vanicat@laposte.net \
/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