You are not logged in.

#1 2010-03-22 09:20:05

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,965
Website

Haskell State Monad Tutorial: looking for feedback

I've written a tutorial of sorts for the Haskell state monad because I found it hard to grok at first (at least as a Haskell noob coming from an imperative background) and none of the explanations that I've found dissect it this way.

You can find it here.

If you know your way around Haskell,  take a look and let me know if I've made any mistakes.
If you're learning Haskell and you're ready to take on the state monad, let me know if you find the tutorial useful.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#2 2010-03-22 10:15:54

wuischke
Member
From: Suisse Romande
Registered: 2007-01-06
Posts: 630

Re: Haskell State Monad Tutorial: looking for feedback

I'll have to read it again to fully understand it, but I already learned some interesting things, thanks for the write-up!

I've just a question about word choice since I'm no native speaker of English:

We're threading the state through a succession of state transformers

You use the word "thread" here. May I think of it like pulling a thread (state) through the eyes of some needles (state transformers)? I'm pretty sure it's not related to threading as in parallel execution threads.

Offline

#3 2010-03-22 23:40:56

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,965
Website

Re: Haskell State Monad Tutorial: looking for feedback

wuischke wrote:

May I think of it like pulling a thread (state) through the eyes of some needles (state transformers)?

Yes, that's the meaning that I intended. It might be more useful to think of threading beads than needles because we usually only thread one needle at a time.

I'll add the bead analogy to the text. Thanks for the feedback. smile


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#4 2010-05-06 16:50:03

CBM80
Member
Registered: 2010-05-06
Posts: 6

Re: Haskell State Monad Tutorial: looking for feedback

Just IMO you should replace the expression 'state transformer' with 'state transition function', mainly to avoid confusion with monad transformers. The 'All About Monads' tutorial talks about state transition functions and I think that term is more accurate.

Offline

#5 2010-05-06 17:39:22

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,965
Website

Re: Haskell State Monad Tutorial: looking for feedback

I'm thinking about your suggestion but so far I can't decide whether or not to implement it.

Looking through the text, I agree that "transition" works in most cases (e.g.  "state transformer" -> "state transition function", stateTransformer -> stateTransitionFunction). At the same time, I see the function inside the state monad as a function which takes a state and changes (transforms) it, yielding a new state. I would say that the application of the function leads to a transition of state. My first instinct is to say that it's a matter of perspective. If you focus on the function, it's a transformation. If you focus on the state, it's a transition.

I want to give it a bit more thought before I decide.

Do you really think there's any risk of confusion with monad transformers? Also, what did you think of the tutorial in general?


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#6 2010-05-07 13:48:59

CBM80
Member
Registered: 2010-05-06
Posts: 6

Re: Haskell State Monad Tutorial: looking for feedback

Chapter 14 of RWH Book explains the state monad pretty well. To be honest I found that your tutorial makes things overly complex.

Offline

#7 2010-05-08 15:11:14

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,965
Website

Re: Haskell State Monad Tutorial: looking for feedback

oh well


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

Board footer

Powered by FluxBB