@@ -8,23 +8,31 @@ import qualified Data.Map as M
8
8
import Types
9
9
import PrettyPrint
10
10
11
- lintTipToi :: TipToiFile -> Segments -> IO ()
11
+ lintTipToi :: TipToiFile -> Segments -> IO (Bool )
12
12
lintTipToi tt segments = do
13
13
let hyps = [ (hyp1, " play indicies are correct" )
14
14
, (hyp2, " media indicies are correct" )
15
15
, (hyp3, " at most one jump per line, as last action" )
16
16
]
17
- forM_ hyps $ \ (hyp, desc) -> do
17
+ hyp_result <- forM hyps $ \ (hyp, desc) -> do
18
18
let wrong = filter (not . hyp) (concat (mapMaybe snd (ttScripts tt)))
19
19
if null wrong
20
- then printf " All lines do satisfy hypothesis \" %s\" !\n " desc
20
+ then do
21
+ printf " All lines do satisfy hypothesis \" %s\" !\n " desc
22
+ return True
21
23
else do
22
24
printf " These lines do not satisfy hypothesis \" %s\" :\n " desc
23
25
forM_ wrong $ \ line -> do
24
26
printf " %s\n " (ppLine M. empty line)
27
+ return False
25
28
26
- forM_ (fromMaybe [] (ttMediaFlags tt)) $ \ f ->
27
- when (f > 1 ) $ printf " Media flag >1: %d" f
29
+ media_result <- forM (fromMaybe [] (ttMediaFlags tt)) $ \ f ->
30
+ if (f > 1 )
31
+ then do
32
+ printf " Media flag >1: %d" f
33
+ return False
34
+ else do
35
+ return True
28
36
29
37
let overlapping_segments =
30
38
filter (\ ((o1,l1,_),(o2,l2,_)) -> o1+ l1 > o2) $
@@ -33,6 +41,9 @@ lintTipToi tt segments = do
33
41
printf " Overlapping segments: %d\n "
34
42
(length overlapping_segments)
35
43
mapM_ (uncurry report) overlapping_segments
44
+
45
+ let no_failures = (all (== True )) $ (hyp_result ++ media_result ++ [null overlapping_segments])
46
+ return no_failures
36
47
where
37
48
hyp1 :: Line ResReg -> Bool
38
49
hyp1 (Line _ _ as mi) = all ok as
0 commit comments