Simplifier ticks exhausted: a 10-line case
I was trying to define a function that could take itself as an argument.
newtype MobiusFn a = MobiusFn {
func :: MobiusFn a -> a
}
spin :: MobiusFn a -> a
spin mf = func mf mf
Use it to find suffixes of a String
suffixes :: String -> [String]
suffixes = spin $ MobiusFn suffixesMF
where suffixesMF _ [] = []
suffixesMF mf s@(_:xs) = s : spin mf xs
Add main
and compile
main = readLn >>= (print . suffixes)
The compiler panicked with
[1 of 1] Compiling Main ( test.hs, test.o )
ghc: panic! (the 'impossible' happened)
(GHC version 8.0.1 for i386-unknown-linux):
Simplifier ticks exhausted
When trying UnfoldingDone mf_s1UD
But if we ignore the empty string case, it works well with non-empty strings.
suffixes :: String -> [String]
suffixes = spin $ MobiusFn suffixesMF
where suffixesMF _ s@[_] = [s]
suffixesMF mf s@(_:xs) = s : spin mf xs
Two versions tested.
GHC version 8.0.1 for i386-unknown-linux
GHC version 7.10.3 for i386-unknown-linux
Thank you for reading.
Trac metadata
Trac field | Value |
---|---|
Version | 8.0.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | high |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |