[GHC] #15679: Use String rather than [Char] where possible
GHC
ghc-devs at haskell.org
Wed Sep 26 12:51:22 UTC 2018
#15679: Use String rather than [Char] where possible
-------------------------------------+-------------------------------------
Reporter: simonpj | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone: 8.6.1
Component: Compiler | Version: 8.6.1
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: None/Unknown
Unknown/Multiple |
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.
2. 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.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15679>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list