travitch / persistent-vector

Persistent vectors for Haskell based on array mapped tries
BSD 3-Clause "New" or "Revised" License
27 stars 4 forks source link

arrayCompare is complicated and surprising #27

Closed treeowl closed 3 years ago

treeowl commented 3 years ago

arrayCompare for arrays of the same size seems to use lexicographical ordering from right to left, rather than the conventional left to right. It's also implemented in a confusing way. I'd expect something vaguely like

arrayCompare xs ys = compare (length xs) (length ys) <> foldr go EQ [0..length xs - 1]
  where
    go i r = compare (index xs i) (index ys i) <> r