Skip to content

fromString from Data.Text.Lazy.Builder generates massive amount of code #549

@TheKK

Description

@TheKK

The code sample looks like

{-# LANGUAGE OverloadedStrings #-}

f :: B.Builder
f = "a cat" <> "a dog" <> "a fish"

By using Builder from bytestring, the above code generates about 30 lines of core (compiler explorer), but we got 2200 lines when switching to text (compiler explorer)

This becomes a problem since I use katip for logging and it uses Builder from text internally. It's very common to use string literal to construct Builder while logging.

Possible root cause and solution

fromString has INLINE

This is the most obvious reason why it produce so many code. They are inlined three times and it seems that there's nothing (eg. RULE) to make them shorter.

But it's hard for me to tell if removing INLINE would make performance worse or not. (And I see no benchmark involve fromString)

Related issue

#19 (it's issue of pre 2.0 text which still use RULE to fuse though)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions