Vlad the Impala
Vlad the Impala

Reputation: 15882

Writer vs WriterT in Haskell

What is the difference between Writer and WriterT in Haskell? Is one preferred over the other?

Upvotes: 10

Views: 1656

Answers (2)

dino
dino

Reputation: 1133

To add to the excellent explanations above, I'd like to also point to this paper. Has helped me quite a bit:

Monad Transformers Step By Step

Upvotes: 4

hammar
hammar

Reputation: 139930

The difference is that Writer is a monad, whereas WriterT is a monad transformer, i.e. you give it some underlying monad, and it gives you back a new monad with "writer" features on top. If you only need the writer-specific features, use Writer. If you need to combine its effects with some other monad, such as IO, use WriterT.

Upvotes: 16

Related Questions