diff options
Diffstat (limited to 'debug-me.hs')
-rw-r--r-- | debug-me.hs | 6 |
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 |