From beefe1ac20bff0a804ca7214a84fa96c4d4ef479 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Mon, 13 Mar 2017 11:33:46 -0400 Subject: [PATCH] Extract the definition of the empty state. --- src/SES/Myers.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/SES/Myers.hs b/src/SES/Myers.hs index 4130b4a1a..b3795229e 100644 --- a/src/SES/Myers.hs +++ b/src/SES/Myers.hs @@ -43,7 +43,7 @@ data Direction = Forward | Reverse -- Evaluation runMyers :: HasCallStack => (a -> a -> Bool) -> Myers a b -> b -runMyers eq = runAll $ MyersState (Vector.replicate 100 0) (Vector.replicate 100 0) +runMyers eq = runAll emptyState where runAll state step = case runMyersStep eq state step of Left a -> a Right next -> uncurry runAll next @@ -183,6 +183,9 @@ getEq = GetEq `Then` return data MyersState = MyersState { forward :: !(Vector.Vector Int), backward :: !(Vector.Vector Int) } +emptyState :: MyersState +emptyState = MyersState (Vector.replicate 100 0) (Vector.replicate 100 0) + setForward :: Vector.Vector Int -> Myers a () setForward v = modify (\ s -> s { forward = v })