Skip to content

sortOn with tuple of >= 9 Maybe's triggers ghc: panic! with "Simplifier ticks exhausted"

Given the following code (full Stack project attached):

module Foo where

import Data.List

data MyRecord = MyRecord {
    f1 :: Maybe String
  , f2 :: Maybe String
  , f3 :: Maybe String
  , f4 :: Maybe String
  , f5 :: Maybe String
  , f6 :: Maybe String
  , f7 :: Maybe String
  , f8 :: Maybe String
  , f9 :: Maybe String
  , f10 :: Maybe String
  , f11 :: Maybe String
  , f12 :: Maybe String
  }

getComparisonValue x = (
    f1 x
  , f2 x
  , f3 x
  , f4 x
  , f5 x
  , f6 x
  , f7 x
  , f8 x
  , f9 x
  )

doSort = sortOn getComparisonValue

The following error results:

$ stack build
ghc-bug-0.0.0: build (lib)
Preprocessing library ghc-bug-0.0.0...
[1 of 1] Compiling Foo              ( Foo.hs, .stack-work/dist/x86_64-linux-nopie/Cabal-1.24.2.0/build/Foo.o )
ghc: panic! (the 'impossible' happened)
  (GHC version 8.0.2 for x86_64-unknown-linux):
	Simplifier ticks exhausted
  When trying UnfoldingDone $j_s72t
  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: 324566

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug


--  While building package ghc-bug-0.0.0 using:
      /home/kostmo/.stack/setup-exe-cache/x86_64-linux-nopie/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-linux-nopie/Cabal-1.24.2.0 build lib:ghc-bug --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1

Generating a tuple from elements of an object for the purpose of sorting is an idiom I have used in Python at times.

The original use case in Haskell for me was excluding some fields of the record in the comparison (e.g. f10, f11, f12 fields), rather than using a simple sort with deriving Ord on MyRecord. I worked around the issue for now by blanking out the record fields I with to ignore, instead of re-instantiating a tuple of field values:

getComparisonValue x = x {
    f10 = Nothing
  , f11 = Nothing
  , f12 = Nothing
  }
Trac metadata
Trac field Value
Version 8.0.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information