caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jun Furuse <jun.furuse@gmail.com>
To: Drup <drupyog+caml@zoho.com>
Cc: caml-list <caml-list@inria.fr>, Alain Frisch <alain@frisch.fr>,
	oleg@okmij.org
Subject: Re: [Caml-list] [ANN] ppx_monadic.1.0.2, ppx for monadic do, pattern
Date: Tue, 20 Jan 2015 11:53:52 +0800	[thread overview]
Message-ID: <CAAoLEWtKzvNk1yViX0y3a1Wd=6Q3_GMSz-CZRy-3ic=BbC5=AA@mail.gmail.com> (raw)
In-Reply-To: <54BD7CBB.50409@zoho.com>

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

I know what you wrote, since I always asked myself "isn't it too bizarre?"
when I was writing ppx_monadic. Here are some justifications I made:

The first intension of ppx_monadic is to port my code with pa_monad without
pain. Unfortunately ppx_monad required too many small fixes due to the
following reasons:

·       "perform" needed to be replaced by "begin%monad .. end" or "[%monad
.. ]" which requires closing, which is really pain. Ppx_monad provides
"fun%monad", "match%monad" without closing but they were not always helpful
for me.
·       The pattern "p" of "p <- e" is limited to a variable, since it
overrides the syntax of object member mutation. In addition, I use lots of
monadic binds inside my class methods. Therefore this override is not
acceptable for me.

Secondary, I see the monadic syntax sugar is to reduce the number of key
types, and I accepted some alien syntax weirdness for the purpose. If the
number of key types would not matter, I would be happy with the good old
bind (>>=) chains and would not use "do" at all. People think bind chains
are hard to read but my experience with Jane Street Async tells me it it
not quite. Ppx_monad does not really gain in this point unfortunately: I
was often forced to write "let%monad (x,y) = e in" just for "(x,y) <-- e;".
I write Haskell do-notations daily and wanted to have something comparable
in OCaml.

Anyway, the current OCaml syntax is limited to have do-notation which makes
everyone happy. If there would be a way in OCaml to write "foo e" for some
keyword "foo" which is like "begin" but does not require "end", I would be
pretty happy to change the weird "Option.do_; e" to "foo%Option e". Before
implementing "do_; e", I tried a bit of "[%do] e" but it did not work well
since "[%do] p <-- e" is parsed as "([%do] p) <-- e", not "[%do] (p <-- e)".

Best,
Jun
On 20 Jan, 2015 5:53 am, "Drup" <drupyog+caml@zoho.com> wrote:

>
>  I can appreciate that authors of tools that requires special syntactic
>> support would love to have their new forms look completely native to users,
>> but the counter-argument can be made that keeping an explicit syntax
>> (through the '%' character) for features that are not part of the official
>> language is a good property. (Camlp4/campl5 are still available for people
>> who want to play with the concrete syntax.)
>>
>
> I personally like the explicitness of the syntax a lot. The only issue in
> OCaml currently is that, given the need for retro compatibility, it goes
> sometimes against the terseness. For example the impossibility to do " x@foo"
> instead of "x[@foo]". That's unavoidable, though.
>
> This is, by the way, a point I dislike a lot with ppx_monadic. It abuses
> the native syntax in completely alien ways and without annotations.
>
> I like ppx_monad's syntax quite better due to the fact that it's always
> explicitly a ppx (thanks to %monad) and do not overload the "do_"
> identifier.
>
>

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

      reply	other threads:[~2015-01-20  3:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-13 14:23 [Caml-list] [ANN] ppx_monadic.1.0.2, ppx for monadic do, pattern guards and monadic comprehension Jun Furuse
2015-01-14  8:40 ` [Caml-list] [ANN] ppx_monadic.1.0.2, ppx for monadic do, pattern oleg
2015-01-18 14:47   ` Jun Furuse
2015-01-19  7:33     ` [Caml-list] [ANN] ppx_monadic.1.0.2, ppx for monadic do, oleg
2015-01-19  8:34       ` Alain Frisch
2015-01-19  9:06         ` Gabriel Scherer
2015-01-19  9:40           ` Alain Frisch
2015-01-19 16:10             ` Jeremy Yallop
2015-01-19  8:56     ` [Caml-list] [ANN] ppx_monadic.1.0.2, ppx for monadic do, pattern Alain Frisch
2015-01-19 21:52       ` Drup
2015-01-20  3:53         ` Jun Furuse [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='CAAoLEWtKzvNk1yViX0y3a1Wd=6Q3_GMSz-CZRy-3ic=BbC5=AA@mail.gmail.com' \
    --to=jun.furuse@gmail.com \
    --cc=alain@frisch.fr \
    --cc=caml-list@inria.fr \
    --cc=drupyog+caml@zoho.com \
    --cc=oleg@okmij.org \
    /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).