Fix sparseset expansion checks

Signed-off-by: magic_rb <richard@brezak.sk>
This commit is contained in:
magic_rb 2024-01-27 16:59:38 +01:00
parent 8cba80004d
commit 5b3f55817b
No known key found for this signature in database
GPG key ID: 08D5287CC5DDCA0E

View file

@ -15,6 +15,7 @@ import Data.Vector.Storable qualified as VS hiding (length, replicate, take)
import Data.Vector.Storable.Mutable qualified as VS
import Data.Vector.Unboxed qualified as VU hiding (length, replicate, take)
import Data.Vector.Unboxed.Mutable qualified as VU
import Debug.Trace (traceShowId)
import Foreign.Storable
import Prelude hiding (lookup)
@ -51,7 +52,7 @@ onLeft
onLeft g f = f >>= either g pure
checkBounds :: (Monad m) => Int -> Int -> ExceptT () m ()
checkBounds maxN idx = unless (idx >= 0 && idx <= maxN) (throwError ())
checkBounds maxN idx = unless (idx >= 0 && idx < maxN) (throwError ())
exists :: (PrimMonad m) => SparseSet m a -> Int -> m Bool
exists (SparseSet sparseSet') idx = onLeft (const $ pure False) $ runExceptT do