GHC 9.4+ hangs indefinitely when compiling the monus-weighted-search package
Summary
GHC 9.4+ hangs indefinitely when compiling the Control.Monad.Heap module in the monus-weighted-search package.
The hang seems to happen in the Constructed Product Result analysis.
Steps to reproduce
git clone https://github.com/oisdk/monus-weighted-search.gitcd monus-weighted-search- Observe the following terminates:
cabal build -w ghc-9.2.8 lib:monus-weighted-search - Observe the following hangs indefinitely:
cabal build -w ghc-9.4.1 lib:monus-weighted-search
Additional diagnostic steps that confirm the issue location:
- Update
monus-weighted-search.cabalso theghc-optionsincludes-v - Observe
cabal build -w ghc-9.4.1 lib:monus-weighted-searchgets stuck in the Constructed Product Result analysis*** Simplifier [Control.Monad.Heap]: Result size of Simplifier iteration=1 = {terms: 10,731, types: 40,759, coercions: 17,664, joins: 12/491} Result size of Simplifier iteration=2 = {terms: 10,711, types: 40,727, coercions: 16,669, joins: 12/487} Result size of Simplifier = {terms: 10,711, types: 40,727, coercions: 16,669, joins: 12/487} !!! Simplifier [Control.Monad.Heap]: finished in 106.51 milliseconds, allocated 182.290 megabytes *** Demand analysis [Control.Monad.Heap]: Result size of Demand analysis = {terms: 10,711, types: 40,727, coercions: 16,669, joins: 12/487} !!! Demand analysis [Control.Monad.Heap]: finished in 19.83 milliseconds, allocated 32.152 megabytes *** Constructed Product Result analysis [Control.Monad.Heap]: - Update
monus-weighted-search.cabalso theghc-optionsincludes-fno-strictness - Observe
cabal build -w ghc-9.4.1 lib:monus-weighted-searchterminates
Expected behavior
GHC should successfully compile the package. Alternatively, if there is an issue with the code, GHC should report an error rather than hang indefinitely.
Environment
- GHC version used: 9.4.1, 9.4.2, 9.4.4, 9.4.8, 9.6.6, 9.10.1 (confirmed hanging in all these versions), 9.2.8 (confirmed terminating)
- Operating System: macOS 15.3.2
- System Architecture: arm64