What is the difference between a monad and a closure?

后端 未结 4 1071
别跟我提以往
别跟我提以往 2021-02-08 11:24

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

4条回答
  •  时光取名叫无心
    2021-02-08 12:23

    A "closure" is an object comprising 1) a function, and 2) the values of its free variables where it's constructed.

    A "monad" is a class of functions that can be composed in a certain way, i.e. by using associated bind and return higher-order function operators, to produce other functions.

提交回复
热议问题