[Haskell] Real life examples

Judah Jacobson judah.jacobson at gmail.com
Wed Nov 24 01:35:53 EST 2004

On Tue, 23 Nov 2004 20:50:45 -0800, John Meacham <john at repetae.net> wrote:
> On Mon, Nov 22, 2004 at 05:03:30PM +0100, Benjamin Franksen wrote:
> > You have been asked more than once to present a *real-life* example to
> > illustrate that
> >
> > (a) global variables are necessary (and not just convenient),
> > (b) both above mentioned alternatives are indeed unworkable.
> First of all, there are a couple issues here that are getting
> mixed up in the discussion. One is that no one is arguing for everyone
> to use global variables, their disadvantages are well known. However, we
> do see a practical NEED for a mechanism in the language to create
> top-level monadic bindings.  The existance of other mechanisms to
> achieve the same thing only STRENGTHENS the argument for them, they
> won't break anything because we already have them, but will be actually
> safe, rather than coincidentally safe due to the peculiarities of the
> ghc optimizer and absurdly more efficient.
> Motivated. I decided to do some grepping and bring up some examples.

Very nice survey of practical applications!  To futher clarify the
discussion, though, I'd like to note two distinct uses of

1) encapsulating referentially transparent IO actions into pure functions
2) creating one-time-actions / top-level-mutable-variables / TWI's

For example, in your example of Atom.hs, the top-level hashtable would
be #2, while the pure external interface is #1.  I believe your post
addressed #2, please correct me if otherwise.

I bring this up because there are two _separate_ debates happening on
the haskell lists that are often confused or combined.  Using the same
numbering as above, they are:
1) whether values like getArgs or stdout are safe enough to be pure
values (i.e., referentially transparent)
2) whether TWI's/etc are necessary, and if so whether to implement them
    - as a language extension like top-level (x <- someAction), or
    - as an all-purpose library (such as George Russell's recent post)
using e.g. Dynamics or semaphores

Does this seem like a fair summary?  

-Judah Jacobson

More information about the Haskell mailing list