You are not logged in.
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 Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
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
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.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
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
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 Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Chapter 14 of RWH Book explains the state monad pretty well. To be honest I found that your tutorial makes things overly complex.
Offline
oh well
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline