[英]Haskell “show is applied to too many type arguments”
我試圖在haskell中復制UNIX程序wc。 為了使這更容易,我創建了一個類型:
data WCResult = WCResult {
wordCount :: Int,
fileName :: String
} --deriving (Show)
instance Show (WCResult x y) where
show (WCResult x y) = show x ++ " " ++ y
當我嘗試運行這個程序時,我得到了
wc.hs:9:15:
`WCResult' is applied to too many type arguments
In the instance declaration for `Show (WCResult x y)'
有誰知道為什么?
類型WCResult
不接受任何參數 - 您將類型構造函數與數據構造函數混淆,后者確實接受了參數:
instance Show WCResult where
show (WCResult x y) = show x ++ " " ++ y
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.