Exponential compilation slowdown with ImplicitParams extension.

Dmitry Vyal akamaus at gmail.com
Fri Oct 18 21:52:28 UTC 2013


Greetings,
recently GHC-7.6.2 hung while compiling my program. I was able to minify 
it to this:

{-# LANGUAGE ImplicitParams #-}

data D = D Int deriving Show

slow_to_compile :: IO ()
slow_to_compile = do
   tst1 <- return 1

   let ?tst1 = tst1
   let ?tst2 = tst1
   let ?tst3 = tst1
   let ?tst4 = tst1
   let ?tst5 = tst1
   let ?tst6 = tst1
   let ?tst7 = tst1

   print $ D ?tst1

The compilation finishes actually. But it's very slow. The time depends 
on number of implicit parameter bindings. Looks like it grows as 
exponential function of it.

As a workaround you can explicitly specify type for tst1.

Is it a known issue?

Best regards,
Dmitry


More information about the ghc-devs mailing list