If you read my earlier post about compound actions, you’ll probably remember that I’m using Hymn for monads. Just recently version 0.5 was released. The most interesting new feature for me are monad-> and monad->> threading macros. These work similarly to -> and ->> macros in standard library, but are supposed to be used with monads.
These allow writing the previous example in a shorter format:
(defn lunge [character direction] (do-monad [moved-1 (move character direction) moved-2 (move moved-1 direction) attacked (attack moved-2 direction)] attacked))
can be written as:
(defn lunge [character direction] (monad-> (move character direction) (move direction) (attack direction)))
Quite a nifty looking piece of code, isn’t it?