0
試圖實現與Maybe相同的應用程序。在compliation 得到噸的錯誤,最喜歡定製應用程序可能
Couldn't match expected type ‘FixMePls b’
with actual type ‘Maybe a1’
的代碼是我做錯了什麼,歡迎如下
data FixMePls a = FixMe | Pls a deriving (Eq, Show)
instance Monoid a => Monoid (FixMePls a) where
mempty = Nothing
mappend m Nothing = m
mappend Nothing m = m
mappend (Pls a) (Pls a') = Pls (mappend a a')
instance Applicative FixMePls where
pure = Pls
Nothing <*> _ = Nothing
_ <*> Nothing = Nothing
Pls f <*> Pls a = Pls f a
main :: IO()
main = do
putStrLn("Weee!!!1!")
任何提示。我懷疑它是數據類型聲明,但不知道如何解決它。
它告訴你,這是期待'FixMePls B'(即或者一個'FixMe'或一個'Pls'),但它有一個'Maybe a'(即'Just'或'Nothing')。 –