caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Anthony Tavener <anthony.tavener@gmail.com>
To: Hendrik Boom <hendrik@topoi.pooq.com>
Cc: dario.teixeira@yahoo.com, "caml-list@inria.fr" <caml-list@inria.fr>
Subject: Re: [Caml-list] octothorpes and backticks?
Date: Fri, 10 Jun 2016 14:04:40 -0600	[thread overview]
Message-ID: <CAN=ouMRM47s1LM098+oGiN2f28S79LFzRveJx1KK+LQQxgKs-g@mail.gmail.com> (raw)
In-Reply-To: <20160610190503.GA29121@topoi.pooq.com>

[-- Attachment #1: Type: text/plain, Size: 1711 bytes --]

Backticks are for Polymorphic Variants...

Documentation is in plain sight... and yet kind of hidden. :) Here's the
Polymorphic Variants section of the manual:
http://caml.inria.fr/pub/docs/manual-ocaml/lablexamples.html#sec46

And at the bottom of the "Advanced Use" subsection it introduces the
abbreviated syntax for matching.

The Polymorphic Variant chapter of Real World OCaml might be useful too,
though I couldn't see any reference to the abbreviated matching with #,
even in the subtyping topic in the Objects chapter.

On Fri, Jun 10, 2016 at 1:05 PM, Hendrik Boom <hendrik@topoi.pooq.com>
wrote:

> On Fri, Jun 10, 2016 at 06:25:57PM +0000, dario.teixeira@yahoo.com wrote:
> > Hi,
> >
> > > (b) Is there any way to do a run-time type-test on a value of a
> > > specific statically known supertype to test whether it is actually a
> > > value of a known specified subtype, and if so to proceed to use it as
> > > that subtype?
> >
> > I reckon the "#" syntax may be what you are looking for.
> > It works with polymorphic variants and objects (types
> > where row-polymorphism applies).  Small example:
> >
> > type foo = [ `A | `B | `C ]
> > type bar = [ `D | `E | `F ]
> > type foobar = [ foo | bar ]
> >
> > let f = function
> >   | #foo -> "Foo"
> >   | #bar -> "Bar"
>
> Haven't encountered the 3 syntax or the ` syntax.  Where is it
> docuumented, so I can start to understand?
>
> -- hendrik
>
> >
> > Hope this helps!
> > Best regards,
> >
> > Dario Teixeira
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>

[-- Attachment #2: Type: text/html, Size: 2761 bytes --]

  reply	other threads:[~2016-06-10 20:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-10 18:12 [Caml-list] reverse coercions Hendrik Boom
2016-06-10 18:25 ` dario.teixeira
2016-06-10 19:05   ` [Caml-list] octothorpes and backticks? Hendrik Boom
2016-06-10 20:04     ` Anthony Tavener [this message]
2016-06-10 18:34 ` [Caml-list] reverse coercions Gerd Stolpmann
     [not found] ` <CAPFanBFa+MJzvt_KYmReuHSzRpD=fT=nEaXB4c7dMwWSL3w7Vg@mail.gmail.com>
2016-06-10 18:59   ` Hendrik Boom

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='CAN=ouMRM47s1LM098+oGiN2f28S79LFzRveJx1KK+LQQxgKs-g@mail.gmail.com' \
    --to=anthony.tavener@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=dario.teixeira@yahoo.com \
    --cc=hendrik@topoi.pooq.com \
    /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;
as well as URLs for NNTP newsgroup(s).