Top level string literals
At the moment GHC's internal language does not allow any top-level definitions of unlifted type, and for the most part rightly so. But consider this:
f :: Int -> String
f n = let a::Addr# = "foo"
in let g y = ...a...g...
in g n
Here we'd like to float the definitions out thus:
a::Addr# = "foo"
g y = ...a...g...
f n = g n
This is much better. Usually this happens, but not here, because we don't allow a top-level binding for an Addr#
. But really perhaps we should allow an exception for literals, which can safely be bound at top level.
For literals other than strings, this doesn't make any difference, because we inline them freely. But for literal strings we don't want to make lots of copies of them; on the contrary we'd like to CSE identical strings. So it'd help to be able to bind them at top level.
Simon