From 5b3f55817bf2e1d72cd988b22162fc1597bdb988 Mon Sep 17 00:00:00 2001 From: magic_rb Date: Sat, 27 Jan 2024 16:59:38 +0100 Subject: [PATCH] Fix sparseset expansion checks Signed-off-by: magic_rb --- rpg/src/Stores/SparseSet.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rpg/src/Stores/SparseSet.hs b/rpg/src/Stores/SparseSet.hs index b53413c..10c6985 100644 --- a/rpg/src/Stores/SparseSet.hs +++ b/rpg/src/Stores/SparseSet.hs @@ -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