开发者

Haskell - error by execution

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)

开发者_Go百科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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜