简体   繁体   English

Pure在Haskell中的Free monad是什么意思?

[英]What does Pure mean in Free monad in Haskell?

I try to learn free monads. 我尝试学习免费的monad。 I found following: 我发现以下内容:

data Free f r = Free (f (Free f r)) | Pure r

What does Pure mean? Pure是什么意思? And why do I need r with Pure? 为什么我需要Pure的r?

Pure corresponds to the return operation -- conceptually it attaches to your functor the ability to "inject" a value. Pure对应于return操作-从概念上讲,它使您的函子可以“注入”值。 The Free constructor corresponds to "join". Free构造函数对应于“ join”。

If you want to understand why you "need" Pure , try to remove it and give the Monad instance and see where you get stuck! 如果您想了解为什么“需要” Pure ,请尝试将其删除并提供Monad实例,以查看卡住的地方!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM