Reputation: 187
I try to write a this monad
data W x = W x [String]
instance Monad W where
return x = W x []
W a h1 >>= f = case f a of
W b h2 -> W b (h1++h2)
But, now when i will use this monad and try to write return or >>= in code I get by compilation the warnings:
No explicit method nor default method for Prelude.return in the instance declaration. No explicit method nor default method for Prelude.>>= in the instance declaration.
Does anyone know how to fix this warnings?
thank you very much
Upvotes: 2
Views: 279
Reputation: 3510
Assuming that the layout of the code is exactly as displayed in your question, the problem is that your return
and >>=
definitions are not indented, so they are being defined as new top-level functions unrelated to the Monad class. Indent them and it should work.
Upvotes: 6