module Main where
newtype Rec a b = Rec {deRec :: Rec a b -> a}
infixl 1 >|>
infixl 1 <|<
(>|>) = Rec
(<|<) (Rec x) = x
fix f = (\x -> f (x <|< x)) (Rec (\x -> f (x <|< x)))
factorial = fix (\f x -> if x<=1 then 1 else x*f(x-1))
main = do
x <- getLine
putStrLn (show (factorial (read x)))
GHC response:
ghc: panic! (the 'impossible' happened)
(GHC version 7.6.3 for x86_64-apple-darwin):
Simplifier ticks exhausted
When trying UnfoldingDone a_sMx{v} [lid]
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: 7121
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
What's wrong?
-fsimpl-tick-factorprint "foo"and removingfactorial.-fsimpl-tick-factor=25000(250 times the default value!) the error still occurs. More than that causes thrashing for me. Looks like infinite iterative unfolding of some of your constructs. Where did you get that code from (is it your own?)