Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: Thomas.Fischbacher@Physik.Uni-Muenchen.DE
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] environment idiom
Date: Mon, 13 Dec 2004 21:09:40 +0900 (JST)	[thread overview]
Message-ID: <20041213.210940.74758065.garrigue@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <Pine.LNX.4.58.0412131035150.13773@eiger.cip.physik.uni-muenchen.de>

From: Thomas Fischbacher <Thomas.Fischbacher@Physik.Uni-Muenchen.DE>
> On Mon, 13 Dec 2004, Jacques Garrigue wrote:
> 
> > > Of course, it's possible to just forget about all that and fall back to 
> > > transliterating imperative code to IO monad code, but it is just as well 
> > > possible to find the sum of all the numbers from 1 to 1000 using the 
> > > following piece of Maple code:
> > 
> > You make me curious. Most of the code I've seen using the IO monad (or
> > the state transformer monad) was just transliterating imperative to
> > monadic code. Of course using closures, but not that much, and you can
> > certainly do that in an impure functional language also.
> 
> First, I should perhaps mention that in my point of view, John does have a 
> valid point in what he says. It's only that he expressed it in a way I 
> just *cannot* agree with.

OK, so probably we almost agree.
Three days ago I was about to answer John that indeed he has a good
point, but he seems to ignore completely the other advantages of
monads, like the fact you can cleanly mix stateful code with pure
code, keeping the two separate.

> > So what is so incredible about the IO monad?
> 
> There is nothing "in-credible" about it. It is just plainly nothing else 
> as working with values that describe "plans" to do IO. We do have a magic 
> place that can bring such plans to life, causing them to be executed, but 
> from the pure Haskell point of view this is not relevant. All we do is to 
> construct plans how to do IO.

So maybe the problem goes back to the compositional vs. pointwise view
of things. While the compositional view is nice, at some level of
detail I find it simpler to reason pointwise (even when purely
functional).
My real curiosity was about the kind of compositional abstractions one
would use with stateful computations. It seems to me that the presence
of state itself makes it more difficult to compose cleanly. At least,
types help you less: they let you now that there is state around, but
not the detail of how this state is used (maybe I'm not up-to-date
with recent Haskell.)

> > Of course according to your definition this contains nothing that is
> > not referentially transparent once you've taken the syntactic sugar.
> 
> Precisely. To go a bit more into detail:

No need to explain: I know this is referentially transparent :-)
My only point was that it doesn't _look_ so.

> In a certain sense, this "do" notation - which is NOT a special extension 
> of the powers of pure, functional haskell but only a short-hand notation 
> for things that can be spelled out explicitly - is "poison" that allows 
> one to "just hack one's imperative thoughts into haskell without 
> even having know about the abstract point of view". This is a bit like 
> FORTRAN programmers asked to adjust themselves to C showing the attitude 
> that "at least, they can forget all that for/while/etc. mumbo-jumbo and 
> do everything with goto, as they are used to".

I wonder whether this is really so.
Some programs without the do notation would be much harder to read.
Do you really think they can all be rewritten to cleaner alternative
code?

> Coming back to the original question, which was whether one may "just 
> stick in some monadic stuff to get a notion of an `environment'", I'm 
> inclined to say that from the purely functional point of view, this 
> perhaps is not a good idea, as this is not just "a minor change to the 
> code" but changes pretty much anything of its original properties.

Having worked on parameterization systems a long time ago, I can only
agree.
The trouble with the monadic view of environment is that you quickly
end up making all your functions monadic, introducing some
sequentiality which may have no reason to be. While being no expert of
the question, this seems to be a tendency of monads: they are
so comfortable that they tend to pollute everything, diluting the
advantage of knowing exactly what is functional. But how can you stop
people from going the easy way?

       Jacques Garrigue


  reply	other threads:[~2004-12-13 12:09 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-09  2:07 HENRIKSON, JEFFREY
2004-12-09  4:47 ` [Caml-list] " Jacques Garrigue
2004-12-09  6:02   ` Michael Walter
2004-12-09 11:28     ` Jacques Garrigue
2004-12-09 20:02     ` pad
2004-12-09 23:11       ` Jacques Garrigue
2004-12-10  2:30         ` skaller
2004-12-09  9:09 ` Richard Jones
2004-12-09 13:12   ` [Caml-list] " Ville-Pertti Keinonen
2004-12-10 11:59     ` Richard Jones
2004-12-10 10:52 ` [Caml-list] " Andrej Bauer
2004-12-10 12:13   ` Richard Jones
2004-12-10 23:35     ` Jacques Garrigue
2004-12-11  2:30   ` skaller
2004-12-11 14:31     ` Andrej Bauer
2004-12-11 18:13       ` Markus Mottl
2004-12-11 23:56         ` skaller
2004-12-12  2:36           ` William Lovas
2004-12-12  5:33             ` skaller
2004-12-12 19:09               ` Michael Walter
2004-12-13  0:48                 ` skaller
2004-12-13  2:03                   ` Michael Walter
2004-12-13  2:05                     ` Michael Walter
     [not found]                       ` <877e9a170412121844b633bb8@mail.gmail.com>
2004-12-13  2:45                         ` Michael Walter
2004-12-13  6:18                           ` skaller
2004-12-13  7:08                             ` skaller
2004-12-13  9:56                             ` Michael Walter
2004-12-13 12:59                               ` skaller
2004-12-13  8:56                           ` Thomas Fischbacher
2004-12-13  9:21                             ` Jacques Garrigue
2004-12-13 10:05                               ` Michael Walter
2004-12-13 10:29                                 ` Thomas Fischbacher
2004-12-13 21:16                                   ` Michael Walter
2004-12-13 10:20                               ` Thomas Fischbacher
2004-12-13 12:09                                 ` Jacques Garrigue [this message]
2004-12-13 12:48                                   ` Thomas Fischbacher
2004-12-13 14:09                                   ` skaller
2004-12-13 21:39                                     ` Michael Walter
2004-12-13 13:22                                 ` skaller
2004-12-13 16:54                                   ` Marcin 'Qrczak' Kowalczyk
2004-12-13 18:44                                   ` Thomas Fischbacher
2004-12-13 10:11                             ` Michael Walter
2004-12-13 11:46                             ` skaller
2004-12-13  5:41                     ` skaller
2004-12-13  9:29                       ` Michael Walter
2004-12-13 12:30                         ` skaller
2004-12-13 13:49                           ` Martin Berger
2004-12-12 23:03           ` Thomas Fischbacher
2004-12-13  1:26             ` skaller
2004-12-13  8:37               ` Thomas Fischbacher
2004-12-13 10:53                 ` skaller
2004-12-13 11:38                   ` Martin Berger
2004-12-13 13:33                     ` skaller
2004-12-13 12:01                   ` Thomas Fischbacher
2004-12-13 13:41                     ` skaller
2004-12-11 23:29       ` skaller
2004-12-12  0:21         ` Jacques Carette

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=20041213.210940.74758065.garrigue@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=Thomas.Fischbacher@Physik.Uni-Muenchen.DE \
    --cc=caml-list@inria.fr \
    /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