summaryrefslogtreecommitdiffhomepage
path: root/debug-me.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2017-04-12 16:14:47 -0400
committerJoey Hess <joeyh@joeyh.name>2017-04-12 16:14:47 -0400
commitddb32ffb75bc78ce1004a7ddedc1ed2c54eccadb (patch)
tree50aa6a8893ce3a308570d97cfd7cf39d0e2c617a /debug-me.hs
parent80fb3d85b2b9a30e8b717dc63aaca75d346f5667 (diff)
downloaddebug-me-ddb32ffb75bc78ce1004a7ddedc1ed2c54eccadb.tar.gz
fix bug
Forgot to include the most recent backlog when checking echoData
Diffstat (limited to 'debug-me.hs')
-rw-r--r--debug-me.hs6
1 files changed, 4 insertions, 2 deletions
diff --git a/debug-me.hs b/debug-me.hs
index a0d7476..bd80f01 100644
--- a/debug-me.hs
+++ b/debug-me.hs
@@ -15,6 +15,7 @@ import System.Exit
import qualified Data.ByteString as B
import Data.List.NonEmpty (NonEmpty(..), toList)
import Data.Monoid
+import Debug.Trace
main :: IO ()
main = do
@@ -199,10 +200,11 @@ truncateBacklog (Backlog bl) _ = Backlog bl
-- concatenation of all activities after that one, up to the most recent
-- Seen activity.
isLegal :: Activity Entered -> Backlog -> Bool
-isLegal (Activity entered hp sig) (Backlog ((lastseenhash, _lastseen) :| bl))
+isLegal (Activity entered hp sig) (Backlog (last@(lastseenhash, _lastseen) :| bl))
| lastseenhash == hp = True
+ | B.null (echoData entered) = False -- optimisation
| any (== hp) (map fst bl) =
- let sincehp = reverse (takeWhile (\(h, _) -> h /= hp) bl)
+ let sincehp = reverse (last : takeWhile (\(h, _) -> h /= hp) bl)
in echoData entered == mconcat (map (seenData . activityContent . snd) sincehp)
| otherwise = False
isLegal _ _ = False