Simplifier ticks exhausted When trying UnfoldingDone ip_X7RI
When trying compiling the following code I get a ghc panic
import Network.Wai
import Network.Wai.Handler.Warp
import Network.HTTP.Types
( status200
, status404)
import Blaze.ByteString.Builder (copyByteString)
import qualified Data.ByteString.UTF8 as BU
import Data.Monoid
main = do
let port = 3000
putStrLn $ "Listening on port " ++ show port
run port app
app req respond =
respond
$ case pathInfo req of
["avOK"] -> avOK
["avWrong"] -> avWrong
x -> index x
avOK =
responseBuilder
status200
[("Content-Type", "text/html")]
$ mconcat
$ map copyByteString
[ "<!DOCTYPE html>"
, "<html>"
, "<head>"
, "<title>Title</title>"
, "</head>"
, "<body>"
, "<div class=\"status\">"
, "In stock, usually dispatched in 1 business day"
, "</div>"
, "</body>"
, "</html>"]
avWrong =
responseBuilder
status404
[("Content-Type", "text/html")]
$ mconcat
$ map copyByteString ["<p>wong!</p>"]
index x =
responseBuilder
status200
[("Content-Type", "text/html")]
$ mconcat
$ map copyByteString
[ "<p>Hello from "
, BU.fromString $ show x
, "!</p>"
, "<p><a href='/yay'>yay</a></p>\n" ]
We get
<no location info>:
ghc: panic! (the 'impossible' happened)
(GHC version 7.10.2 for x86_64-unknown-linux):
Simplifier ticks exhausted
When trying UnfoldingDone ip_X7RI
To increase the limit, use -fsimpl-tick-factor=N (default 100)
If you need to do this, let GHC HQ know, and what factor you needed
To see detailed counts use -ddump-simpl-stats
Total ticks: 53522k
After a little bit of debugging I realised that it's the copyBytestring
imported from import Blaze.ByteString.Builder
function that is causing trouble, by reducing the number of elements in the list the function doesn't crash the compiler, so for instance:
avOK =
responseBuilder
status200
[("Content-Type", "text/html")]
$ mconcat
$ map copyByteString
[ "<!DOCTYPE html>"
, "<html><head><title>Title</title></head>"
, "<body>"
, "<div class=\"status\">"
, "In stock, usually dispatched in 1 business day"
, "</div>"
, "</body>"
, "</html>"]
compiles happily. I'm using
- bytestring-0.10.6.0
- wai-3.0.4.0
- warp-3.1.8
- http-types-0.8.6
- blaze-builder-0.4.0.1
- utf8-string-1.0.1.1