我定义了一个名为 Stack 的类,如下所示:
class Stack stack where
push :: a -> stack a -> stack a
top :: MonadPlus m => stack a -> m (a,stack a)
empty :: stack a
isEmpty :: stack a -> Bool
但是当我实现这些方法时
instance Stack [] where
push b bs = b:bs
top [] = mzero
top (b:bs) = return(b,bs)
empty = []
isEmpty [] = True
isEmpty _ = False
我收到了这个警告:
Warning: No explicit implementation for
`Types.push', `Types.top', `Types.empty', and `Types.isEmpty'
In the instance declaration for `Stack []'
我不知道为什么会出现这个警告。我看到可能与缩进有关,但我不知道问题出在哪里。