[GHC] #2840: Top level string literals
GHC
ghc-devs at haskell.org
Wed Aug 16 00:02:09 UTC 2017
#2840: Top level string literals
-------------------------------------+-------------------------------------
Reporter: simonpj | Owner: (none)
Type: bug | Status: closed
Priority: lowest | Milestone: 7.6.2
Component: Compiler | Version: 6.10.1
Resolution: duplicate | Keywords: strings
Operating System: Unknown/Multiple | Architecture:
Type of failure: Runtime | Unknown/Multiple
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Changes (by bgamari):
* keywords: => strings
Old description:
> 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
New description:
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:
{{{#!hs
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:
{{{#!hs
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
--
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/2840#comment:10>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list