Use String rather than [Char] where possible
Try this in GHCi
Prelude> :t "foo"
"foo" :: [Char]
It would be better to say
"foo" :: String
Why don't we? Because of this in TysWiredIn
stringTy :: Type
stringTy = mkListTy charTy -- convenience only
That is, where GHC needs String
is uses stringTy
which is just [Char]
.
How to fix? Two ways:
- Make
String
into a "wired-in type". That's not hard, but it increases the number of wired-in types, which is generally undesirable. - Make
String
into a "knonw-key name", and look it up in the type environment on the (few) occasions where we needstringTy
. That's a little harder -- notablyhsLitType
would become monadic -- but not difficult.
Trac metadata
Trac field | Value |
---|---|
Version | 8.6.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |