Changing a light bulb.

Jay Cox
Thu, 28 Feb 2002 21:48:07 -0600 (CST)

On Thu, 28 Feb 2002, Shawn P. Garbett wrote:

> Hash: SHA1
> Now after my earlier soap box tirade I'm trying to put my code where my mouth
> is. >>blush<< It's harder than I thought.
> I've broken it down into a State Model of a light bulb. The goal, to find out
> just how much Haskell code does it take to change the state of a light bulb?
> Here's a very crippled version. Is there an easy way to introduce state
> without changing the type of main???

Rhe IO monad IS a state monad without fetch and assign.

(I'd hate to see it written in the traditional \s -> (s,v) sense, one
fetch of the state gives you gigabytes of information that is on the
computer, and then you'd have to include at least part of the 2^whatever
bytes on all the other computers on the internet.  Oh yeah, did i mention
if you actually interface such a monad with reality, the state would have
to include every bit of information with in the universe! Imagine, all of
that dumped out, all with one single fetch!)



> I've written a much more complex example, but I got into things like
> main :: STT(IO)
> using a monad transformer.

I did similar not to long ago on one of these lists, but it was more of an
example of using a monad transformer for another goal.

> So really, the big question is, must I use a monad transformer?

I'm confused as to what your goal is :)
(plus I don't know where your previous post is).

It doesn't seem like all that much code.  Much of it is the definition of
the state monad.

Jay Cox