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的响应:
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
出了什么问题?
print "foo"
替换 main 函数内的所有内容并删除factorial
,该错误仍然会发生。 - Uli Köhlernewtype
。 - Philip JF