[Haskell-beginners] Global variable question

Joe Van Dyk joe at fixieconsulting.com
Thu Dec 31 12:37:10 EST 2009

On Wed, Dec 30, 2009 at 6:05 PM, Edward Z. Yang <ezyang at mit.edu> wrote:
> Excerpts from Joe Van Dyk's message of Wed Dec 30 20:49:12 -0500 2009:
>> What's the appropriate way to write this in Haskell?
> Hi Joe,
> The Ticker class is an example of stateful computation, which we try
> to avoid in Haskell.  What are you really trying to do?
> * If you a number, and you want to add to it, (+1) works
>  plenty well.
> * If you are going to be making ticks, but you don't care about
>  reading the ticks until the end of the computation, the Writer monad
>  is of interest.
> * If you need to update the tick count and read it, the State
>  monad is a good bet.
> * If you're interested in curiosities from imperative land, STRef, IORef and
>  other similar creatures may be helpful.

It's like haskell is on a personal vendetta against me to make me feel dumb.

Joe Van Dyk

More information about the Beginners mailing list