Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我尝试学习免费的单子。我发现以下内容:
data Free f r = Free (f (Free f r)) | Pure r
纯是什么意思?为什么我需要 r 和 Pure?
Pure对应于return操作——从概念上讲,它赋予你的仿函数“注入”一个值的能力。构造Free函数对应于“join”。
Pure
return
Free
如果您想了解“需要”的原因Pure,请尝试将其删除并给出Monad实例,然后看看您卡在哪里!
Monad