RuF
RuF

Reputation: 558

What does Pure mean in Free monad in Haskell?

I try to learn free monads. I found following:

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

What does Pure mean? And why do I need r with Pure?

Upvotes: 0

Views: 251

Answers (1)

sclv
sclv

Reputation: 38893

Pure corresponds to the return operation -- conceptually it attaches to your functor the ability to "inject" a value. The Free constructor corresponds to "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!

Upvotes: 1

Related Questions