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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 615A77F6D8 for ; Sun, 18 Jan 2015 15:47:17 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of jun.furuse@gmail.com) identity=pra; client-ip=74.125.82.169; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="jun.furuse@gmail.com"; x-sender="jun.furuse@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of jun.furuse@gmail.com designates 74.125.82.169 as permitted sender) identity=mailfrom; client-ip=74.125.82.169; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="jun.furuse@gmail.com"; x-sender="jun.furuse@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-we0-f169.google.com) identity=helo; client-ip=74.125.82.169; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="jun.furuse@gmail.com"; x-sender="postmaster@mail-we0-f169.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: An0BAAHHu1RKfVKplGdsb2JhbABag1hYBMYthXUCgQYHQwEBAQEBEQEBAQEHCwsJEjCEDQEBBBIVGQEbHgMMBgULDS4iAREBBQEcBgESIod1AQMRsBE+MY0ZgneJYQoZJw1Ug0gBAQgBAQEBGAEFDo9yhCkFiWyIJ4VIigOGPRIjgRWEHTExgkMBAQE X-IPAS-Result: An0BAAHHu1RKfVKplGdsb2JhbABag1hYBMYthXUCgQYHQwEBAQEBEQEBAQEHCwsJEjCEDQEBBBIVGQEbHgMMBgULDS4iAREBBQEcBgESIod1AQMRsBE+MY0ZgneJYQoZJw1Ug0gBAQgBAQEBGAEFDo9yhCkFiWyIJ4VIigOGPRIjgRWEHTExgkMBAQE X-IronPort-AV: E=Sophos;i="5.09,421,1418079600"; d="scan'208";a="96807421" Received: from mail-we0-f169.google.com ([74.125.82.169]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 18 Jan 2015 15:47:16 +0100 Received: by mail-we0-f169.google.com with SMTP id p10so3849381wes.0 for ; Sun, 18 Jan 2015 06:47:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=OOPXcF4ciPVVA3L860zJP949co+lL42rXbT6cRfG158=; b=BH3GtieFiy/fuZ0l5S1cA70bnZ8bMTNm3cmQQe3MPJ/Y1P19JNYzmiLui42j4/5cSj s0ohq/8zZVqiRuHsclbujWH4Vl54YcT0D0nFjvC6M2DenPakLZ3gwn29MOTHfVLm9NKY w7VZZ6OfsR5Yp0w5We2qjJ0ya1D0Kl5LGmsBjoLU1dhUebBkdjqF63VJej3U9cSGYn64 dIVKbQ6wcnVMuJg0YS8xWX0W7QXnGMGw1aY+1TMkvx+9sah+0sPaxR8q+k/GpOWW4dTo 9x86sYZn0NoO1rKD4jUtrqcXD6S4PKzvdQurU9AA4KqdbHjOXQBLakbf1dkARZa300js Exng== MIME-Version: 1.0 X-Received: by 10.180.90.206 with SMTP id by14mr8929417wib.0.1421592436350; Sun, 18 Jan 2015 06:47:16 -0800 (PST) Received: by 10.194.100.130 with HTTP; Sun, 18 Jan 2015 06:47:16 -0800 (PST) In-Reply-To: <20150114084056.140F6C38A1@www1.g3.pair.com> References: <20150114084056.140F6C38A1@www1.g3.pair.com> Date: Sun, 18 Jan 2015 22:47:16 +0800 Message-ID: From: Jun Furuse To: oleg@okmij.org, caml-list Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [Caml-list] [ANN] ppx_monadic.1.0.2, ppx for monadic do, pattern Thanks, let! is not valid in the vanilla syntax therefore I guess you have patched the compiler. Current OCaml syntax has shortage of pattern binding expression and only usable is let%xxx p = e in which is a bit pain for ppx writers. The pattern part of p <-- e is actually an expression and you cannot simply write real patterns like (x, y) as z. You still can write it using an extension like [%p? (x,y) as z] but it is lousy... Jun On Wed, Jan 14, 2015 at 4:40 PM, wrote: > > Jun Furuse wrote: >> * Monadic do notation: do_; >> * Pattern guards: when p <-- e -> .. > > This reminds me: MetaOCaml incorporates the let! notation suggested by > Nicolas Pouillard and implemented by Alain Frisch. The following is > the example of using the notation, excerpted from the file > metalib/test/pythagorian_triples.ml > in the BER MetaOCaml distribution/source. > > (* The example uses left recursion and truly infinite streams! *) > (* Don't try this in Prolog or in Haskell's MonadPlus. *) > > let rec numb () = (* infinite stream of integers *) > yield (mplus (let! n = numb in ret (n+1)) (* left recursion! *) > (ret 0)) () > ;; > > let pyth : (int * int * int) NonDet.stream = > let! i = numb in > let! () = guard (i>0) in > let! j = numb in > let! () = guard (j>0) in > let! k = numb in > let! () = guard (k>0) in > (* Just to illustrate the `let' form within let! *) > let test x = x*x = j*j + k*k in > let! () = guard (test i) in > ret (i,j,k) > ;; > > let [(5, 4, 3); (5, 3, 4); (10, 8, 6); (10, 6, 8); (13, 12, 5); (13, 5, 12); > (15, 12, 9); (15, 9, 12); (17, 15, 8); (17, 8, 15)] > = > run 10 pyth;; > > > (The file also implements the non-determinism monad that is > illustrated in the example.) >