# 055: showList のデフォルト実装ではエラー [↑up](bunny_notes) - issued: 2020-05-03 - 分類: 分類:C 改善項目 - status: Closed (2020-05-13) ## 概要 showList について、class Show のデフォルト実装ではエラーするので、 Int, Integer それぞれに特殊実装を書いて回避している。 deriving Show は実現するまえに、この件対処が必要。 $$
{
instance Show Integer where
show = Prim.integerShow
showList xs = (++) (showlist' xs)
where showlist' [] = "[]"
showlist' [x] = "[" ++ Prim.integerShow x ++ "]"
showlist' (x:xs) = "[" ++ foldl (\s t -> s ++ "," ++ Prim.integerShow t) (show x) xs ++ "]"
$$}
$${
instance Show Int where
show = Prim.intShow
showList xs = (++) (showlist' xs)
where showlist' [] = "[]"
showlist' [x] = "[" ++ Prim.intShow x ++ "]"
showlist' (x:xs) = "[" ++ foldl (\s t -> s ++ "," ++ Prim.intShow t) (show x) xs ++ "]"
$$}
## 調査ログ
### 2020-05-08
以下のようにすると、showlogs' が多相になる:
$${
instance Show Integer where
show = Prim.integerShow
showList xs = (++) (showlist' xs)
where showlist' [] = "[]"
showlist' [x] = "[" ++ show x ++ "]"
showlist' (x:xs) = "[" ++ foldl (\s t -> s ++ "," ++ show t) (show x) xs ++ "]"
-- showlist' :: [Integer] -> [Char]
$$}
そのときの Core をみると、辞書の解決がなんか変な気がする。
小さいテストケースで再現したので、そちら([067](bissue067))で調査しよう。
### 解決
[067](bissue067) 対処により、本件も解決。lib/Prelude.hs を修正して、クローズ。