
#14880: GHC panic: updateRole -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: goldfire Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.2.2 checker) | Resolution: | Keywords: TypeInType Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: #15076 | Differential Rev(s): Phab:D4769 Wiki Page: | -------------------------------------+------------------------------------- Comment (by tdammers): Replying to [comment:58 simonpj]:
the "unions" approach: unions . map singleton
That is essentially `foldr (union . singleton) empty`, which is really very close to `foldr insert empty`.
What if you do a balanced tree of binary `union` operations? I suppose something like {{{ bigSet :: Int -> Int -> IntSet bigSet m n | m==n = singleton n | otherwise = bigSet m mid `union` bigSet (mid+1) n where mid = (n+m)/2 }}}
Did exactly that, benchmark code attached. Results: {{{ ./intmapbench insert 1.32s user 0.05s system 99% cpu 1.370 total ./intmapbench union 1.01s user 0.01s system 99% cpu 1.029 total ./intmapbench balanced 0.24s user 0.01s system 98% cpu 0.260 total }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14880#comment:64 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler