1
1
mirror of https://github.com/github/semantic.git synced 2024-12-29 18:06:14 +03:00

🔥 checkK.

This commit is contained in:
Rob Rix 2017-06-13 17:17:29 -04:00
parent c2e2526d9d
commit b6fc6917d3

View File

@ -119,13 +119,12 @@ runSES eq (EditGraph as bs)
-- | Return the maximum extent reached and path taken along a given diagonal.
getK k = do
v <- checkK k
v <- gets unMyersState
let (x, script) = v ! k in return (Endpoint x (x - unDiagonal k) script)
-- | Update the maximum extent reached and path taken along a given diagonal.
setK k (Endpoint x _ script) = do
v <- checkK k
put (MyersState (v Array.// [(k, (x, script))]))
setK k (Endpoint x _ script) =
modify (MyersState . (Array.// [(k, (x, script))]) . unMyersState)
-- | Slide down any diagonal edges from a given vertex.
slideFrom (Endpoint x y script)
@ -165,13 +164,6 @@ v ! i | inRange (Array.bounds v) i = v Array.! i
| otherwise = let ?callStack = fromCallSiteList (filter ((/= "M") . fst) (getCallStack callStack)) in
throw (MyersException ("index " <> show i <> " out of bounds") callStack)
-- | Check that a given diagonal is in-bounds for the edit graph, returning the actual index to use and the state array.
checkK :: Diagonal -> Myers a b (Array.Array Diagonal (Int, EditScript a b))
checkK k = do
v <- gets unMyersState
unless (inRange (Array.bounds v) k) $ fail ("diagonal " <> show k <> " outside state bounds " <> show (Array.bounds v))
return v
-- | Lifted showing of arrays.
liftShowsVector :: Show i => (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Array.Array i a -> ShowS