You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
lehmacdj
changed the title
State monad + other monads defined in transformers are out of date due to transformerification of them
State monad + other monads defined in transformers are out of date
Feb 17, 2022
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 theState
constructor which no longer exists. Unfortunately this isn't a perfect solution because we maybe need to explain / at least somewhat excuseStateT
/ 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
The text was updated successfully, but these errors were encountered: