summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2014-07-27 20:51:13 +0200
committertv <tv@shackspace.de>2014-07-27 20:51:13 +0200
commit6160fbfd34179b660586f88d4dec5dfe14173fbf (patch)
tree50d7d995e8af5e6eebbbf844b9a7df5b8643118f
parent75ebdc58d851ae101ca8d801ea8eae72d74bdf0d (diff)
instance Monoid Command
-rw-r--r--Main.hs24
1 files changed, 24 insertions, 0 deletions
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 ()