我刚刚发明了以下替代定义Maybe
:
type Maybe' a = forall b. (b -> (a -> b) -> b)
just :: a -> Maybe' a
just a = \d f -> f a
nothing :: Maybe' a
nothing = const
bind :: Maybe' a -> (a -> Maybe' b) -> Maybe' b
bind ma f = ma nothing (\a -> f a)
问题是我无法添加以下实例声明
instance Monad (Maybe') where
return = just
a >>= f = bind a f
错误信息是:
Type synonym Maybe' should have 1 argument, but has been given none
有什么办法可以解决吗?