learnyouahaskell.github.io
learnyouahaskell.github.io copied to clipboard
State monad + other monads defined in transformers are out of date
This is a pain point that I still remember from when I first learned Haskell using Learn You a Haskell probably almost 5 years ago.
Is your content edit request related to a problem? Please describe.
The definition of the State monad and probably most monads defined in transformers is outdated. See for example this code snippet; it no longer compiles with modern versions of Haskell/base/transformers because State has been redefined to be type State s a = StateT s Identity a
:
https://github.com/learnyouahaskell/learnyouahaskell.github.io/blob/main/docs/for-a-few-monads-more.html#L1405-L1413
Describe the solution you'd like
The code snippet above should be modified to use the state
function instead of the State
constructor which no longer exists. Unfortunately this isn't a perfect solution because we maybe need to explain / at least somewhat excuse StateT
/ monad transformers before one really would want to pedagogically.
Describe alternatives you've considered
Encourage people to define the monad themselves and not import it in the examples. Then continue to use the older definition of the state monad throughout. This is maybe better, because it avoids the complications of monad transformers. If we go with this approach it might be a good idea to mention that
Additional context
This same problem also appears to affect at least Writer
on the same page.
Link to the page in question
https://learnyouahaskell.github.io/for-a-few-monads-more.html#state
Thanks a lot for your point. What modern book or paper do you suggest to learn the topic?..