Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between a monad and a closure?

i am kinda confused reading the definition between the two. Can they actually intersect in terms of definition? or am i completely lost? Thanks.

like image 891
user63657 Avatar asked Apr 26 '09 11:04

user63657


1 Answers

Closures, as the word tends to be used, are just functions (or blocks of code, if you like) that you can treat like a piece of data and pass to other functions, etc. (the "closed" bit is that wherever you eventually call it, it behaves just as it would if you called it where it was originally defined). A monad is (roughly) more like a context in which functions can be chained together sequentially, and controls how data is passed from one function to the next.

like image 55
Max Strini Avatar answered Oct 08 '22 13:10

Max Strini