mirror of
https://git.sr.ht/~magic_rb/haskell-games
synced 2024-11-22 07:44:20 +01:00
Fix sparseset expansion checks
Signed-off-by: magic_rb <richard@brezak.sk>
This commit is contained in:
parent
8cba80004d
commit
5b3f55817b
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue