Skip to content

Examples of State monad usage? #1418

Answered by louthy
rhemsuda asked this question in Q&A
Nov 26, 2024 · 2 comments · 8 replies
Discussion options

You must be logged in to vote

You don't seem to be following much of the advice I've given so far? The previous response about packaging up the subsystems with bespoke monadic types is really the way to go. It looks like you're mixing:

  • Either - which is a very low feature monad, it has only an alternative value
  • IO (I think) - it looks like you're calling Run inline, which is definitely not a good idea if you want pure code. It injects all of the side-effects at the point of invocation.
  • Using stateful (non-static) classes which you're reading from in an impure way.
  • Dependency Injection frameworks. Which are pure evil.

This approach is not gaining you anything. The code is neither declarative nor is it easy to write. …

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
5 replies
@rhemsuda
Comment options

@rhemsuda
Comment options

@rhemsuda
Comment options

@kirill-gerasimenko-da
Comment options

@louthy
Comment options

Answer selected by rhemsuda
Comment options

You must be logged in to vote
3 replies
@rhemsuda
Comment options

@aloslider
Comment options

@rhemsuda
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants