Commit 86ddf8a9 authored by Ben Gamari's avatar Ben Gamari
Browse files

Show: Activate literal rewrite rules in simplifier phase 2

Previously these RULES were quite fragile as they could compete with the
`unpack` rule defined in `GHC.Base`. This was tickled by 7.10.2, which
happened to rewrite the LHS of rules with other rules (which is itself
a bug in GHC). This caused the literal rules to fail to fire, which then
resulted in long compilation times.

To avoid this sort of fragility, we would like the literal rules to fire
very early in the simplifier. For this reason we set them to rule in
phase 2.

See GHC Trac #10528 for further discussion [1].

[1] https://ghc.haskell.org/trac/ghc/ticket/10528
parent b114f2a0
......@@ -50,19 +50,19 @@ unpackCString# :: Addr# -> Text
unpackCString# addr# = unstream (S.streamCString# addr#)
{-# NOINLINE unpackCString# #-}
{-# RULES "TEXT literal" forall a.
{-# RULES "TEXT literal" [2] forall a.
unstream (S.map safe (S.streamList (GHC.unpackCString# a)))
= unpackCString# a #-}
{-# RULES "TEXT literal UTF8" forall a.
{-# RULES "TEXT literal UTF8" [2] forall a.
unstream (S.map safe (S.streamList (GHC.unpackCStringUtf8# a)))
= unpackCString# a #-}
{-# RULES "TEXT empty literal"
{-# RULES "TEXT empty literal" [2]
unstream (S.map safe (S.streamList []))
= empty_ #-}
{-# RULES "TEXT singleton literal" forall a.
{-# RULES "TEXT singleton literal" [2] forall a.
unstream (S.map safe (S.streamList [a]))
= singleton_ a #-}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment