Skip to content

GHC can suggest "Probable fixes" that are impossible

Let's say I type in ["foo", 4] to GHCI:

Prelude> ["foo", 4]

<interactive>:1:8:

No instance for (Num [Char])

arising from the literal 4' at <interactive>:1:8 Probable fix: add an instance declaration for (Num [Char]) In the list element: 4 In the definition of it': it = ["foo", 4]

It suggests a "Probable fix": add an instance declaration for (Num [Char]). OK, great. However, as soon as I try to evaluate "instance Num [Char] where" I get

Illegal instance declaration for Num [Char]' (The instance type must be of form (T a b c) where T is not a synonym, and a,b,c are distinct type variables) In the instance declaration for Num [Char]'

Now, I'm not enough of an expert on the type class system to know if this means that it's absolutely impossible to declare instances on [Char], but it certainly seems like that. Thus, the "Probable fix" is in error, since [Char] can't get a Num instance. (Though I guess (Num a) => [a] can, so maybe this whole issue is a little moot.)

Trac metadata
Trac field Value
Version 6.4.1
Type Bug
TypeOfFailure OtherFailure
Priority low
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system Unknown
Architecture Unknown
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information