From: Petter Urkedal <paurkedal@gmail.com>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Purity and lazyness
Date: Sun, 9 Jan 2011 11:00:15 +0100 [thread overview]
Message-ID: <20110109100015.GA25941@eideticdew.org> (raw)
In-Reply-To: <87ipxzhv2b.fsf@mid.deneb.enyo.de>
On 2011-01-08, Florian Weimer wrote:
> * Elias Gabriel Amaral da Silva:
>
> >> As specified, Haskell is not a pure language because every pattern
> >> match can have side effects. The Haskell community is split between
> >> those who think that this is a good thing, and those that consider it
> >> problematic. (Obviously, there is a large pure subset, much more
> >> useful than Erlang's pure subset and covering almost the whole
> >> language; you just avoid lazy I/O and use unsafePerformIO only for
> >> correcting the type of functions imported through FFI.)
> >
> > Wait, a pattern match can have side effects? Can you provide some
> > example code? (do you mean, pattern match failure / exceptions / run
> > time errors?)
>
> <http://article.gmane.org/gmane.comp.lang.haskell.prime/3083>
>
> It uses seq instead of pattern matches for clarity. But laziness
> means that you could hide the side effect in any pattern match
> whatsoever.
Do you mean that pattern matching could be used instead of seq in this
example? But the example is do demonstrate that hGetContents has side
effects, whereas seq is only used to force two different evaluation
orders.
IIUC, the issue with pattern matching is that it may throw an exception,
and exceptions are impure because *if* and *where* they are thrown is
hard to predict, and may affect the outcome of a program witch tries to
catch it.
My experience with Haskell is limited, but I suspect a pattern matching
failure is to be considered a bug, and that the exception mechanism
doubles as a software diagnostic system, like in many languages. That
is, a program should not try to catch those exceptions, except at the
for bug-reporting and recovery purposes. From this point of view,
shouldn't a pattern match be considered pure in a bug-free program?
prev parent reply other threads:[~2011-01-09 10:00 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-07 15:35 Dario Teixeira
2011-01-07 16:07 ` Damien Doligez
2011-01-07 16:38 ` David Rajchenbach-Teller
2011-01-07 18:16 ` Holger Weiß
2011-01-07 20:22 ` Eray Ozkural
2011-01-07 20:29 ` orbitz
2011-01-07 20:30 ` Joel Reymont
2011-01-07 20:33 ` Eray Ozkural
2011-01-08 9:44 ` Jesper Louis Andersen
2011-01-07 17:21 ` Alain Frisch
2011-01-07 17:46 ` Christophe Raffalli
2011-01-07 18:11 ` Holger Weiß
2011-01-07 18:52 ` Brian Hurt
2011-01-07 19:32 ` Petter Urkedal
2011-01-07 20:25 ` Eray Ozkural
2011-01-09 16:11 ` Jon Harrop
2011-01-10 6:27 ` Eray Ozkural
2011-01-07 19:17 ` Florian Weimer
[not found] ` <AANLkTikxCSQ+0XkOmSVDb3EWq_2oQ0pac3bDgc7f7jq+@mail.gmail.com>
2011-01-07 20:52 ` bluestorm
2011-01-09 16:15 ` Jon Harrop
2011-01-08 0:26 ` Elias Gabriel Amaral da Silva
2011-01-08 9:28 ` Christophe Raffalli
2011-01-08 22:47 ` Florian Weimer
2011-01-09 10:00 ` Petter 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=20110109100015.GA25941@eideticdew.org \
--to=paurkedal@gmail.com \
--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