Why is the use of Maybe/Option not so pervasive in Clojure?

后端 未结 7 2176
长发绾君心
长发绾君心 2020-12-24 01:36

Why does Clojure, despite such an emphasis on functional paradigm, not use the Maybe/ Option monad to represent optional values? The use of O

7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-24 01:52

    Well there is a Maybe monad but it uses nil as Nothing, capturing only the abstraction of computation (if input=nil return nil else calc whatever with input)to avoid null pointers errors but it doesnt have the static compile-time safety. There is fnil too that have a similar mission, patching nil with default values and a -?>. I think the clojure way is more oriented to return default values that raise errors or nil.

提交回复
热议问题