caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Petter A. Urkedal" <paurkedal@gmail.com>
To: "Daniel Bünzli" <daniel.buenzli@erratique.ch>
Cc: caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] Terser ppx syntax for common usage (like monads)
Date: Sat, 10 Oct 2015 19:32:53 +0200	[thread overview]
Message-ID: <CALa9pHQHPY3OU25c5eQCQ6vtOWsiW8jaYmogsUsm6AG7Y1B5HA@mail.gmail.com> (raw)
In-Reply-To: <F139F045CACC49BB99932C6BFF5C389F@erratique.ch>

I forgot to CC the list when replying, so sending a digest in
cronological order.  (Including Daniel Bünzli's responses, cited in
good faith.)

====

2015-10-10 16:09 GMT+02:00 Daniel Bünzli <daniel.buenzli@erratique.ch>:
>> Now, that's not necessarily a bad thing, but the monad bind operation
>> tends to be quite invasive, so I'd like to suggest adding a shorter
>> syntax which the user could choose to map to their most pervasive ppx
>> rewriter.
>
> This entails that I can't possibly have an idea of what the code is doing without looking up what the build system is doing which is annoying. We should aim for self-describing sources rather than put too much knowledge in the build systems — which also means that usage of pre-processors should be frown upon in general.

The added opaqueness could be avoided by aliasing kw* to kw%ext for
some ext in the source code.  This would also allow delimiting the
scope.

Though, you raise a more general issue.  Do you have an alternative?
Should people stick with [... >>= fun x -> ...], or should monad
support be added to the compiler?  What about deriving extensions?

====

Le samedi, 10 octobre 2015 à 16:20, Petter A. Urkedal a écrit :

> Though, you raise a more general issue. Do you have an alternative?

Not really.
> Should people stick with [... >>= fun x -> ...],

That's personally what I do for now. I don't like pre-processors since
they do not compose in general and needlessly complicate and opacify
build systems and your code. They do solve real problems, but in the
wrong way. I hope that in a few years we will have something along
this line [1]. Meanwhile I'm willing to stay away as much as possible
from pre-processors…
> or should monad support be added to the compiler?

There was some discussion about this at some point to add some magic
for this on `let` keywords, I don't remember the details but it was
rejected — was kind of an ad-hoc hack to be honest. I wanted to point
you to this but the perspective of having to search the mailing list
archive put me off, I'll let you do that…

Best,

Daniel

[1] http://www.lpw25.net/ocaml2015-abs1.pdf

====

2015-10-10 17:28 GMT+02:00 Daniel Bünzli <daniel.buenzli@erratique.ch>:
> Le samedi, 10 octobre 2015 à 16:20, Petter A. Urkedal a écrit :
>> Should people stick with [... >>= fun x -> ...],
>
> That's personally what I do for now. I don't like pre-processors since they do not compose in general and needlessly complicate and opacify build systems and your code. They do solve real problems, but in the wrong way. I hope that in a few years we will have something along this line [1]. Meanwhile I'm willing to stay away as much as possible from pre-processors…

Yes, a macro system would be better.  I was a bit surprised to see
it's typed, considering the issues of representing typed lambda
calculus within it self [2].  I haven't read that close enough to tell
whether it applies here though.  (The original James Chapman may be an
easier read.)

Your [1] reference is talking about performance, and if one is willing
to give up on that, a canonical rewrite might suffice for common
extensions dealing with control flow:

  let%ext x = y in z --> let_ext y (fun x -> z)
  if%ext x then y else z --> if_ext x (fun () -> y) (fun () -> z)
  while%ext x do y done --> while_ext x (fun () -> y)
  etc.

So, concurrency seems to be non-essential use of syntax extension, as
opposed to deriving and other type-driven extensions.

>> or should monad support be added to the compiler?
>
> There was some discussion about this at some point to add some magic for this on `let` keywords, I don't remember the details but it was rejected — was kind of an ad-hoc hack to be honest. I wanted to point you to this but the perspective of having to search the mailing list archive put me off, I'll let you do that…

Didn't find that, but in any case, it does not sound like a good idea
to let the same construct handle both cases without somehow tagging
the usage as monadic, if that was the magic involved.  In any case, I
think it is good to have a system which decouples the development of
new features from the development of OCaml itself, and to avoid
accreting esoteric features.

[1] http://www.lpw25.net/ocaml2015-abs1.pdf
[2] http://homotopytypetheory.org/2014/03/03/hott-should-eat-itself/

      reply	other threads:[~2015-10-10 17:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-10 13:48 Petter A. Urkedal
2015-10-10 13:57 ` Petter A. Urkedal
2015-10-10 14:09 ` Daniel Bünzli
2015-10-10 17:32   ` Petter A. Urkedal [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=CALa9pHQHPY3OU25c5eQCQ6vtOWsiW8jaYmogsUsm6AG7Y1B5HA@mail.gmail.com \
    --to=paurkedal@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=daniel.buenzli@erratique.ch \
    /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).