From 6160fbfd34179b660586f88d4dec5dfe14173fbf Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 27 Jul 2014 20:51:13 +0200 Subject: instance Monoid Command --- Main.hs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'Main.hs') diff --git a/Main.hs b/Main.hs index 7e4bd0b..465610d 100644 --- a/Main.hs +++ b/Main.hs @@ -116,6 +116,13 @@ data Command -- TODO Move Count Motion -- Delete Count Register Motion -- etc. + | Combine Command Command + | Nop + +instance Monoid Command where + mempty = Nop + mappend = Combine + data ExecError @@ -232,8 +239,25 @@ execCommand (AlertBadInput s) = execCommand (UnboundSequence s n) = throwError (UnboundSequenceError s n) +execCommand (Combine c1 c2) = do + q0 <- get + + ((eSt1, lines1), q1) <- liftIO $ runExecCommand q0 (execCommand c1) + + -- TODO "stack trace" + whenLeft eSt1 throwError + + ((eSt2, lines2), q2) <- liftIO $ runExecCommand q1 (execCommand c2) + + -- TODO "stack trace" + whenLeft eSt2 throwError + + tell lines1 + tell lines2 + put q2 +execCommand Nop = return () -- cgit v1.2.3