[英]Making a custom list ADT instance of Monoid
可能是我想念的東西很明顯,但是似乎應該可以,但是它給Expecting one more argument to 'Star' Expected a type, but 'Star' has kind '* -> *'
提供了一個Expecting one more argument to 'Star' Expected a type, but 'Star' has kind '* -> *'
錯誤,我可以不破譯。
data Star a = None | Union a (Star a)
deriving Show
instance Monoid Star where
mempty = None
mappend None rs = rs
mappend (Union r rs) rst = Union r (mappend rs rst)
只有具體類型(例如Int)可以是Monoid。 Star是類型為*-> *的抽象類型。 編輯:當然(Star a)也可以是Monoid(像[a]),但不能是Star。
instance Monoid (Star a) where
...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.