Monads and Middleware

243 views
Skip to first unread message

Scott Klarenbach

unread,
Jul 1, 2016, 1:14:02 PM7/1/16
to Clojure
I'm looking for some insight into the relationship between Monads and Middleware.

It seems to me that middleware (ala Ring, Boot) is really just a subset of Monads, where bind and lift are globally agreed upon conventions, rather than explicitly defined.  For example, with middleware you need every function to accept and return the same signature so as to be composable, whereas with monads you explicitly provide the code for binding and lifting into and out of the monad world.

My basic questions are:

1.) Is middleware really a monad with a different name?
2.) Is there any compelling reason to use monads in clojure instead of middleware?
3.) Are there classes of problems that can be solved with monads that can't be solved with middleware?
4.) Is there any benefit (beyond curiosity) to porting/re-implementing middleware as monads?

Thanks.

Scott Klarenbach


James Reeves

unread,
Jul 1, 2016, 2:07:53 PM7/1/16
to clo...@googlegroups.com
Functions are a type of monad, and function composition is a type of monadic binding. You could certainly say that middleware are a type of monad, but so many things can be thought of as monads that's not hugely useful in and of itself.

- James

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages