Skip to content

Commit 7912477

Browse files
fix correctness issue with swap2 that was making QuickSort fail on prim-mutable-arrays
1 parent 2b1636f commit 7912477

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/ArrayOperations.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ swap xs i j = let !xi = get xs i
6666
left xs == left ys && right xs == right ys &&
6767
ys == swap xs i j } @-}
6868
swap2 :: HasPrim a => Int -> Int -> (Array a -. Array a)
69-
swap2 i j xs =
69+
swap2 i j xs =
7070
let
71-
!(Ur xi, xs1) = get2 i xs
72-
!(Ur xj, xs2) = get2 j xs1
71+
!((Ur !xi), xs1) = get2 i xs
72+
!((Ur !xj), xs2) = get2 j xs1
7373
xs3 = setLin i xj xs2
7474
xs4 = setLin j xi xs3
7575
in {- xi `pseq` xj `pseq` -} xs4

0 commit comments

Comments
 (0)