0

Does state monad make any sense in Clojure? If so, I would appreciate cases where state monad will be more suitable than mutating Clojure atoms via swap!s or reset!s.

OlegTheCat
  • 4,443
  • 16
  • 24
  • Do a search for "clojure monad" or "clojure state monad", and you'll find several links that will probably be relevant. – Mars Nov 14 '15 at 03:10
  • @Mars Thanks. I'm more or less familiar with state monads and its implementation in Clojure. The question is where and when it is relevant to use state monads instead of other "stateful" stuff. – OlegTheCat Nov 17 '15 at 20:45

2 Answers2

1

You won't bee needing it. But monads are used to build more involved abstractions than plain state. Clojure's core.async's go macro is a state machine and internally it's implemented as a monad. You can watch Tim Baldridge's explanation of it: https://www.youtube.com/watch?v=R3PZMIwXN_g

Ricardo Acuna
  • 530
  • 2
  • 10
0

Monads makes sense if you would prefer to keep the code that way. You can have a (monadic) function which encapsulates state.