# 105: (lib/Prelude.hs) instance Enum Char の定義で types do not unify [↑up](bunny_notes) - issued: 2020-06-07 - 分類: A サンプルコードが fail - status: Closed (2020-10-19) ## 概要 instance Enum Char の宣言を The language report のようにしようとすると、 types do not unify エラー。 現状では、エラーする部分をコメントアウトしてある: $$
{
instance Enum Char where
toEnum = Prim.intToChar
fromEnum = Prim.charToInt
{-
enumFrom c = map toEnum [fromEnum c .. 1114111]
enumFromThen c c' = map [fromEnum c, fromEnum c' .. lastint]
where lastint :: Int
lastint | c' < c = 0
| otherwise = 1114111
-}
$$}
## 調査ログ
## 2020-10-19
書き間違いが原因だった。
$${
--- a/compiler/lib/Prelude.hs
+++ b/compiler/lib/Prelude.hs
@@ -330,14 +330,11 @@ instance Ord Char where
instance Enum Char where
toEnum = Prim.intToChar
fromEnum = Prim.charToInt
- {-
enumFrom c = map toEnum [fromEnum c .. 1114111]
- enumFromThen c c' = map [fromEnum c, fromEnum c' .. lastint]
- where lastint :: Int
- lastint | c' < c = 0
+ enumFromThen c c' = map toEnum [fromEnum c, fromEnum c' .. lastInt]
+ where lastInt | c' < c = 0
| otherwise = 1114111
- -}
-
+
$$}
test/sample305.hs を追加。