Opened 12 months ago

#15679 new bug

Use String rather than [Char] where possible

Reported by: simonpj Owned by:
Priority: normal Milestone: 8.6.1
Component: Compiler Version: 8.6.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:


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:

  1. Make String into a "wired-in type". That's not hard, but it increases the number of wired-in types, which is generally undesirable.
  1. Make String into a "knonw-key name", and look it up in the type environment on the (few) occasions where we need stringTy. That's a little harder -- notably hsLitType would become monadic -- but not difficult.

Change History (0)

Note: See TracTickets for help on using tickets.