English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
environment idiom
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-12-13 (02:45)
From: Michael Walter <michael.walter@g...>
Subject: [Caml-list] environment idiom
> The claims that monadic programming allows side effect
> free transparent purely functional encoding is unquestionably
> bogus.
In your view, would claiming that the stream approach allowed that be
bogus as well?

main :: [Response] -> [Request]

In a pure language, main is obviously pure as well. And still, _given
the proper "invocation" from an impure language_, it allows for I/O.

To paraphrase: Does the mere existance of a "magic main invocation"
(whether a streaming-main or an IO monadic-main) make a language
impure, in your concept?

To stretch it further: Suppose an interpreter for an language X with
the simple syntax:
  X-program := (identifier-name '=' integer-literal)+
and semantics that the value of the identifier with the name "main" is
print. It is not allowed to redefine existing definitions (i.e. mutate
state). Hence every "program" in X is pure, but still an X program
such as "main=42" will have a noticable side effect (namely, printing
42 on the screen). How can that be? <0.5-wink>

Again I believe we are talking about different kinds of "purity".
Thomas is obviously right in that the StateTransformer monad (modulo
unsafe conversions) is pure, you are obviously right in the
(different) point that _running_ an IO fragment has side effects.

Generally, I'm not sure whether it's sensible to qualify other
people's statements as "unquestionably bogus". Everything is relative
<wink> :)