# Talk:State Monad

### From HaskellWiki

(New page: Can someone please rewrite this page? After going through it a number of times, I feel strongly that there is no "intuition" here as claimed to help understand how State actually works.) |
(→Pervasive "simplification" is really an obfuscation: new section) |
||

(One intermediate revision by one user not shown) | |||

Line 1: | Line 1: | ||

− | Can someone please rewrite this page? After going through it a number of times, I feel strongly that there is no "intuition" here as claimed to help understand how State actually works. | + | Can someone please rewrite this page? After going through it a number of times, I feel strongly that there is no "intuition" here, as claimed, to help understand how State actually works. |

+ | |||

+ | == Pervasive "simplification" is really an obfuscation == | ||

+ | |||

+ | "The types have been simplified to protect the innocent." | ||

+ | "At its heart, a value of type (State s a) is a function from initial state s to final value a and final state s: (a,s). These are usually wrapped, but shown here unwrapped for simplicity." | ||

+ | |||

+ | This has to be the height of misunderstanding the prospective reader. How on earth can hiding half the story help in understanding how monads work, and particularly the state monad? | ||

+ | |||

+ | Just taking the return function as an example: | ||

+ | |||

+ | -- ie: (return 5) 1 -> (5,1) | ||

+ | return :: a -> State s a | ||

+ | return x s = (x,s) | ||

+ | |||

+ | This is a lie that is not even self consistent. The function signature shows the return value to be of type State s a, whereas that's clearly not what the "ie:..." example shows, nor the return x s =. Sure, this is "covered" by the glib "unwrapped for simplicity", but if a reader already understands how to get from this fake version to the real version, and understands that this is not valid Haskell, he/she doesn't need this tutorial. | ||

+ | |||

+ | This line of exposition just throws the entire tutorial into the trash can. [[User:Gwideman|Gwideman]] 00:18, 3 March 2013 (UTC) |

## Latest revision as of 00:18, 3 March 2013

Can someone please rewrite this page? After going through it a number of times, I feel strongly that there is no "intuition" here, as claimed, to help understand how State actually works.

## [edit] Pervasive "simplification" is really an obfuscation

"The types have been simplified to protect the innocent." "At its heart, a value of type (State s a) is a function from initial state s to final value a and final state s: (a,s). These are usually wrapped, but shown here unwrapped for simplicity."

This has to be the height of misunderstanding the prospective reader. How on earth can hiding half the story help in understanding how monads work, and particularly the state monad?

Just taking the return function as an example:

-- ie: (return 5) 1 -> (5,1) return :: a -> State s a return x s = (x,s)

This is a lie that is not even self consistent. The function signature shows the return value to be of type State s a, whereas that's clearly not what the "ie:..." example shows, nor the return x s =. Sure, this is "covered" by the glib "unwrapped for simplicity", but if a reader already understands how to get from this fake version to the real version, and understands that this is not valid Haskell, he/she doesn't need this tutorial.

This line of exposition just throws the entire tutorial into the trash can. Gwideman 00:18, 3 March 2013 (UTC)