caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Oleg <oleg@okmij.org>
To: rich@annexia.org
Cc: ptoscano@redhat.com, caml-list@inria.fr
Subject: Re: [Caml-list] What if exn was not an open type?
Date: Fri, 27 Oct 2017 22:58:19 +0900	[thread overview]
Message-ID: <20171027135819.GA4340@Magus.localnet> (raw)
In-Reply-To: <20171025083530.gvggcenrgxolduse@annexia.org>


It is interesting that we have this discussion about, even advocacy
for, monads at the time effects are coming to the front stage. The
language Eff (http://eff-lang.org), which is essentially OCaml, states
right upfront its advantages over monads. (Monads do not compose.)
Daan Leijen talk past month about the web server implemented in Koka
stressed the absence of monads. In Koka, if we need an effectful
operation, we just do it. As the Multicore OCaml project has shown,
effects can be very efficiently implemented. 

I fully agree with Ivan Gotovchits that recommends Rich Jones' code
rely on exceptions rather than monads. Where I disagree is the
contention that ``When you need to write system code or any code that
deals with effects, monads become inevitable sooner or later unless
you're willing to use the escape hatch of mutability.'' Monads are not
inevitable!

First of all, not all effects can be represented as monads (which was
pointed long time ago by Wadler himself). My talk at the ML workshop
last month
        http://okmij.org/ftp/tagless-final/nondet-effect.html
described several other effects that aren't monadic and that
commitment to monads precludes several useful implementations (e.g.,
code generation, which cannot be thought in monadic terms).  Hence,
there is real harm in trying to squeeze everything into a
monad. Incidentally, alternative ideas of effects as interactions go
back to 1970s.

Richard W.M. Jones wrote:
> Having said all that I was writing a little ML language last
> year and I tried to implement a return statement, but it was very
> awkward to work out how to map that to my lambda calculus, so
> I understand how return statements are rather difficult to implement
> in practice.

Perhaps this gives a hint that lambda-calculus isn't the best model of
computation -- as the Founding Father has recognized very early
on. There is a reason he spent his life after ML working on process
calculi. Indeed, it takes lots of hops to implement a simple return
statement -- not to speak about real IO -- whereas it a process
calculus, we just say !a. Done. Sending the result to another process
(or to the context) is a built-in operation. There are no
continuations to pass around or capture, no monads (which become
totally unnecessary), no binding. Erlang has shown very well that this
way of programming is realistic, and rather effective.

lambda-calculus has its uses: it works spectacularly well for what it
has been designed for: expressing definitions (and logical
derivations). However, just because it is possible to express
arithmetic in lambda-calculus does not mean that we should be stuck
with Church-numerals. There are better ways to handle numbers -- and
there are better ways to handle communication and control -- outside
lambda-calculus.

  parent reply	other threads:[~2017-10-27 13:53 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-20  9:56 Malcolm Matalka
2017-10-20 10:55 ` David Allsopp
2017-10-20 11:21   ` Ivan Gotovchits
2017-10-20 11:38     ` Simon Cruanes
2017-10-20 16:54       ` Malcolm Matalka
2017-10-20 19:47         ` Simon Cruanes
2017-10-21 21:15           ` Malcolm Matalka
2017-10-24 13:30       ` Richard W.M. Jones
2017-10-24 19:02         ` Petter A. Urkedal
2017-11-04 18:44           ` Richard W.M. Jones
2017-11-04 18:48             ` SP
2017-11-04 18:53               ` Richard W.M. Jones
2017-11-04 19:03                 ` SP
2017-11-04 19:01             ` Max Mouratov
2017-11-04 19:16             ` octachron
2017-11-05 17:41               ` Richard W.M. Jones
2017-11-05 18:39                 ` Yaron Minsky
2017-11-05 20:49                   ` Gabriel Scherer
2017-11-05 21:48                     ` Yaron Minsky
2017-11-05 21:53                     ` Petter A. Urkedal
2017-11-05 18:02             ` Petter A. Urkedal
2017-11-05 18:24               ` Richard W.M. Jones
2017-11-05 18:55                 ` Petter A. Urkedal
     [not found]         ` <CALa9pHQ-nhWf4T0U5gDiKTduPiEeXSZPQ=DY6N1YNbCXqRohPQ@mail.gmail.com>
2017-10-25  8:35           ` Richard W.M. Jones
2017-10-25  9:12             ` Philippe Veber
2017-10-25 14:52               ` Richard W.M. Jones
2017-10-25 16:37                 ` Ivan Gotovchits
2017-10-25 17:47                   ` SP
2017-10-26  8:06                 ` Malcolm Matalka
2017-10-26  8:11                   ` Xavier Leroy
2017-10-25 13:36             ` Ivan Gotovchits
2017-10-26  7:31             ` Petter A. Urkedal
2017-10-27 13:58             ` Oleg [this message]
2017-10-27 14:24               ` Philippe Veber
2017-10-27 14:49                 ` Leo White
2017-11-01  7:16                 ` Oleg
2017-11-04 17:52                   ` Philippe Veber
2017-10-20 17:07   ` Malcolm Matalka
2017-10-21 21:28 ` Nathan Moreau
2017-10-22 12:39   ` Malcolm Matalka
2017-10-22 13:08     ` Nathan Moreau
2017-10-24 11:11     ` SP
2017-10-24 11:16       ` Gabriel Scherer
2017-10-25 11:30         ` Malcolm Matalka

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=20171027135819.GA4340@Magus.localnet \
    --to=oleg@okmij.org \
    --cc=caml-list@inria.fr \
    --cc=ptoscano@redhat.com \
    --cc=rich@annexia.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).