diff options
Diffstat (limited to 'testsuite/tests/stranal/sigs/T13331.hs')
-rw-r--r-- | testsuite/tests/stranal/sigs/T13331.hs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/testsuite/tests/stranal/sigs/T13331.hs b/testsuite/tests/stranal/sigs/T13331.hs new file mode 100644 index 0000000000..5f4a4a1631 --- /dev/null +++ b/testsuite/tests/stranal/sigs/T13331.hs @@ -0,0 +1,29 @@ +{-# LANGUAGE MagicHash, BangPatterns #-} + +module T13331 (naiveInsertInt) where + +data Map k a = Bin !Int !k a (Map k a) (Map k a) + | Tip + +singleton :: k -> a -> Map k a +singleton k a = Bin 1 k a Tip Tip + +balanceL :: k -> a -> Map k a -> Map k a -> Map k a +balanceL !_ _ !_ !_ = undefined +{-# NOINLINE balanceL #-} + +balanceR :: k -> a -> Map k a -> Map k a -> Map k a +balanceR !_ _ !_ !_ = undefined +{-# NOINLINE balanceR #-} + +-- | Should not unbox `kx`. +naiveInsertInt :: Int -> a -> Map Int a -> Map Int a +naiveInsertInt !kx x Tip = singleton kx x +naiveInsertInt !kx x t@(Bin sz ky y l r) = + case compare kx ky of + LT -> balanceL ky y l' r + where !l' = naiveInsertInt kx x l + GT -> balanceR ky y l r' + where !r' = naiveInsertInt kx x r + EQ -> Bin sz kx x l r + |