From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 5B42B7FD92 for ; Fri, 10 Jun 2016 22:04:42 +0200 (CEST) IronPort-PHdr: 9a23:vjEuHxcwAenOSMa0+3OC43H+lGMj4u6mDksu8pMizoh2WeGdxc+6Yx7h7PlgxGXEQZ/co6odzbGG4ua/BidZusbJmUtBWaIPfidNsd8RkQ0kDZzNImzAB9muURYHGt9fXkRu5XCxPBsdMs//Y1rPvi/6tmZKSV3BPAZ4bt74BpTVx5zukbviqtuMPE4R32r1SIgxBSv1hD2ZjtMRj4pmJ/R54TryiVwMRd5rw3h1L0mYhRf265T41pdi9yNNp6BprJYYAu3SNp41Rr1ADTkgL3t9pIiy7UGCHj20+2AEX24Kvh1NCgnDpFGmD9ai+hf948pw3iWAPM6+Z7czXHz276ptRAXpiw8bMCY+8SfPjctpyqlcpUTyiQZ4xtv9Zp2VM/xvNp/UY94cSHAJCs9XSyxGBJL6c4IRAuwMJ85XqoD8ox0Fqh7oVlrkP//m1jId3iy+5qY9yel0VFyf0Q== Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=anthony.tavener@gmail.com; spf=Pass smtp.mailfrom=anthony.tavener@gmail.com; spf=None smtp.helo=postmaster@mail-wm0-f45.google.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of anthony.tavener@gmail.com) identity=pra; client-ip=74.125.82.45; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="anthony.tavener@gmail.com"; x-sender="anthony.tavener@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of anthony.tavener@gmail.com designates 74.125.82.45 as permitted sender) identity=mailfrom; client-ip=74.125.82.45; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="anthony.tavener@gmail.com"; x-sender="anthony.tavener@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-wm0-f45.google.com) identity=helo; client-ip=74.125.82.45; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="anthony.tavener@gmail.com"; x-sender="postmaster@mail-wm0-f45.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0B0AQCKHFtXfS1SfUpehBR9BoVEpEWFcoYlhQCBeiKEGoFbAoEkBzgUAQEBAQEBAQERAQEJCwsJIS+CMIIVAQEBAwESEQQZARsSCwEDAQsGBQQHDQ0dAgIiAREBBQEKEgYTEhCHcwEDDwgOn0WBMT4xizuBaoJZBYc4ChknAwpSgywBAQEBAQUBAQEBAQEBGAIGEIYXhE2CQ4IqglSCWgWGRQyIEYlJNIFYhCyGMIF0gjeMaYd+hi4SHoEPDw+CMIITHTIBigcBAQE X-IPAS-Result: A0B0AQCKHFtXfS1SfUpehBR9BoVEpEWFcoYlhQCBeiKEGoFbAoEkBzgUAQEBAQEBAQERAQEJCwsJIS+CMIIVAQEBAwESEQQZARsSCwEDAQsGBQQHDQ0dAgIiAREBBQEKEgYTEhCHcwEDDwgOn0WBMT4xizuBaoJZBYc4ChknAwpSgywBAQEBAQUBAQEBAQEBGAIGEIYXhE2CQ4IqglSCWgWGRQyIEYlJNIFYhCyGMIF0gjeMaYd+hi4SHoEPDw+CMIITHTIBigcBAQE X-IronPort-AV: E=Sophos;i="5.26,451,1459807200"; d="scan'208,217";a="221985244" Received: from mail-wm0-f45.google.com ([74.125.82.45]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 10 Jun 2016 22:04:41 +0200 Received: by mail-wm0-f45.google.com with SMTP id m124so5767966wme.1 for ; Fri, 10 Jun 2016 13:04:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=9hKCFuy2XygHKlwmxRo+z/Y+3oTfRiHF3FyGqkeK6Do=; b=VSn3uRi83HBJRZCIe7/3NHYxF8FrvNw/qJvhfoWXvki6ikHM0Yr0MkCj62Nu7XruAO yjvPf7YOSFQVgVLs9lunCQLjRWcfXKpFztjD2BV/ufeCXEtMiir5H/VlZtNXJYUjlnOB JlrOonlfgg7st2/Yd5Z/xEMBkhNtpNsUvg8N8MwDSw+QzCCgXkiTe0y6AozRKk8qguX/ aPvSHcNcwt17FQjGYqNpBlOuoPqM4Tl/7VLJWyJV+Z/30LD4ivpjgobghtoLTms8peFd 7TOqismWVFvsWPmCqgNXF2n0up1IRyMHFSQunP6mMfvnf1uxS8UHuqHokxfDguXMoy+4 k8GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=9hKCFuy2XygHKlwmxRo+z/Y+3oTfRiHF3FyGqkeK6Do=; b=gQ0DDMqpl+QO8mQi2v39TaqFqmwaGOue4MvvImAj2LLjtM30EDP481xX8XSr/+U9Nm PwzOomntM388SSZTYImT41HyQ3HNtezlqAioWgdVxO2cqGnFK/Wug7/zDeH64vu4i2Vu 06bSTsEpTtqOMC0zuDqfgzsgRcL0gBgMCRv3zcxfcys/CzjI8GaKslGKYBRQqeeYbW47 HcDWVBPilU2b530nR9fVoQtaUKE0UACeYPDgMagO5Zq1vbCkIXnUgdxXORTa/JpT2nec DZPPiq8gaUYNdLoswQj8jLlsKC99mb4uEyjgd2dELOupM6hyG3B/w/1uXQhDBTRsr4wU gLSQ== X-Gm-Message-State: ALyK8tI3b4UFnlFW0285P6d1I5bHaheeVVYHZR4h+oZOzi86qqk1/+lbZD0v9WPfObmrBRo28NBU/T/o+/Ej1Q== X-Received: by 10.28.50.194 with SMTP id y185mr570500wmy.51.1465589081486; Fri, 10 Jun 2016 13:04:41 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.18.212 with HTTP; Fri, 10 Jun 2016 13:04:40 -0700 (PDT) In-Reply-To: <20160610190503.GA29121@topoi.pooq.com> References: <20160610181222.GA27973@topoi.pooq.com> <1954387336.802086.1465583157701.JavaMail.yahoo@mail.yahoo.com> <20160610190503.GA29121@topoi.pooq.com> From: Anthony Tavener Date: Fri, 10 Jun 2016 14:04:40 -0600 Message-ID: To: Hendrik Boom Cc: dario.teixeira@yahoo.com, "caml-list@inria.fr" Content-Type: multipart/alternative; boundary=001a114128b896b99a0534f20c47 Subject: Re: [Caml-list] octothorpes and backticks? --001a114128b896b99a0534f20c47 Content-Type: text/plain; charset=UTF-8 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 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 > --001a114128b896b99a0534f20c47 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Backticks are for Polymorphic Variants...
Documentation is in plain sight... and yet kind of hidden. :) Here's t= he Polymorphic Variants section of the manual: http://caml.inria.fr/pub= /docs/manual-ocaml/lablexamples.html#sec46

And at the bott= om 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 Object= s 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, dari= o.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 actuall= y a
> > value of a known specified subtype, and if so to proceed to use i= t 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).=C2=A0 Small example:
>
> type foo =3D [ `A | `B | `C ]
> type bar =3D [ `D | `E | `F ]
> type foobar =3D [ foo | bar ]
>
> let f =3D function
>=C2=A0 =C2=A0| #foo -> "Foo"
>=C2=A0 =C2=A0| #bar -> "Bar"

Haven't encountered the 3 syntax or the ` syntax.=C2=A0 Where is it
docuumented, so I can start to understand?

-- hendrik

>
> Hope this helps!
> Best regards,
>
> Dario Teixeira

--
Caml-list mailing list.=C2=A0 Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocam= l_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

--001a114128b896b99a0534f20c47--