1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 14:21:31 +03:00

Select the empty state specific to a given step.

This commit is contained in:
Rob Rix 2017-03-13 11:34:50 -04:00
parent beefe1ac20
commit 8998884e51

View File

@ -43,7 +43,7 @@ data Direction = Forward | Reverse
-- Evaluation -- Evaluation
runMyers :: HasCallStack => (a -> a -> Bool) -> Myers a b -> b runMyers :: HasCallStack => (a -> a -> Bool) -> Myers a b -> b
runMyers eq = runAll emptyState runMyers eq step = runAll (emptyStateForStep step) step
where runAll state step = case runMyersStep eq state step of where runAll state step = case runMyersStep eq state step of
Left a -> a Left a -> a
Right next -> uncurry runAll next Right next -> uncurry runAll next
@ -183,8 +183,8 @@ getEq = GetEq `Then` return
data MyersState = MyersState { forward :: !(Vector.Vector Int), backward :: !(Vector.Vector Int) } data MyersState = MyersState { forward :: !(Vector.Vector Int), backward :: !(Vector.Vector Int) }
emptyState :: MyersState emptyStateForStep :: Myers a b -> MyersState
emptyState = MyersState (Vector.replicate 100 0) (Vector.replicate 100 0) emptyStateForStep _ = MyersState (Vector.replicate 100 0) (Vector.replicate 100 0)
setForward :: Vector.Vector Int -> Myers a () setForward :: Vector.Vector Int -> Myers a ()
setForward v = modify (\ s -> s { forward = v }) setForward v = modify (\ s -> s { forward = v })