Hymn 0.5 released

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)]

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?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s