2
我有類種類不匹配的實例也許
class Functor f => Pointed f where
pure :: a -> f a
的定義,現在我想作實例Maybe
。爲什麼這不起作用?
instance Pointed (Maybe s) where
pure Nothing = Nothing
pure (Just a) = a
class Functor f where
fmap :: (a->b) -> f a -> f b
錯誤是:
Kind mis-match
The first argument of `Pointed' should have kind `* -> *',
but `Maybe s' has kind `*'
In the instance declaration for `Pointed (Maybe s)'
Failed, modules loaded: none.
我看不出爲什麼'在指出的定義中,f有種* - > *' 對不起,我忘了給一個Functor的定義。我編輯了帖子。特別是,它究竟意味着什麼?:'類Functor f =>尖f'Functor(f)和Functor f之間的區別是什麼? – Gilgamesz
@Gilgamesz因爲術語'f a'出現在'pure'類型中。 –
好吧,你是對的。但請回答: 究竟是什麼意思?:'class Functor f =>指出f' Functor(f)'和'Functor f'之間的區別? – Gilgamesz