Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Too much inlining #19

snoyberg opened this Issue · 7 comments

6 participants


tl;dr: text package's pack function is creating huge chunks of code everywhere.

See Felipe's post to the cafe for more details:

@snoyberg snoyberg referenced this issue in yesodweb/yesod

Too much inlining in Shakespeare? #298


One of problems is that literals produce too much code.

text :: T.Text
text = T.pack "text"
       @ GHC.Types.Char
          @ GHC.Types.Char
          @ GHC.Types.Char

          (GHC.Base.unpackCString# "text")))

I think it could be solved with rewrite rule like that. It should be faster since it avoids lists creation and will produce way less code.

textLiteral :: Addr# → Text
textLiteral = ...

unstream (streamList (map safe (unpackCString# s))) → textLiteral

There used to be such a rule for ByteStrings, but it stopped working not too long ago. See this ticket:


When GHC generates code for anything with non-ASCII characters, it uses unpackCStringUtf8#. It would be really nice if it used unpackCStringUtf8Len# though...

Working on a patch.

@bos bos was assigned
bos commented

I've fixed this in 2b2cb08. Working on backports to older versions of GHC now :-(

bos commented

Tagged and released from 6f64406.

@bos bos closed this

Thanks a lot, @bos!

@snoyberg, we should remove those NOINLINE pack wrappers when building with the fixed text package in order to avoid converting from String every time.

@snoyberg snoyberg referenced this issue from a commit in yesodweb/shakespeare
@snoyberg snoyberg Conditionally turn off NOINLINE fix (bos/text#19) d23497b
@snoyberg snoyberg referenced this issue from a commit in yesodweb/persistent
@snoyberg snoyberg Conditionally turn off NOINLINE fix (bos/text#19) 5b2cc67

@meteficha Agreed, and done. It will be part of the 1.0 release. And I'll have the yesod-platform point to version of text. Thanks again @bos!

@feuerbach feuerbach referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.