Opened 12 years ago

Closed 12 years ago

Last modified 9 years ago

#671 closed bug (wontfix)

GHC can suggest "Probable fixes" that are impossible

Reported by: glasser@… Owned by:
Priority: low Milestone:
Component: Compiler Version: 6.4.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


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

Prelude> ["foo", 4]


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.)

Change History (3)

comment:1 Changed 12 years ago by simonpj

Resolution: wontfix
Status: newclosed

I've changed "Probable" to "Possible" in the HEAD. But I can't see another easy way to make this msg more helpful.

It's be enough to give an instance for Num [a], for example, but I'm leery about trying to second-guess the programmer. And saying "Make Num [Char] satisfiable" which is more correct, probably won't help.


comment:2 Changed 9 years ago by simonmar

Architecture: UnknownUnknown/Multiple

comment:3 Changed 9 years ago by simonmar

Operating System: UnknownUnknown/Multiple
Note: See TracTickets for help on using tickets.