summaryrefslogtreecommitdiff
path: root/src/runchess.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/runchess.hs')
-rw-r--r--src/runchess.hs20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/runchess.hs b/src/runchess.hs
index 27a6da8..5854e57 100644
--- a/src/runchess.hs
+++ b/src/runchess.hs
@@ -21,15 +21,19 @@ readPGN = do
Right games -> return games
applyPGN :: PGN -> IO ()
-applyPGN pgn = printGame (foldM (flip moveSAN) defaultBoard $ moves pgn) pgn
+applyPGN pgn = mapM_ printBoard (seqList [moveSAN m | m <- moves pgn] $ Right defaultBoard)
+ where
+ seqList (f:fs) (Right io) = f io:seqList fs (f io)
+ seqList _ (Left _) = []
+ seqList [] _ = []
printGame :: Either MoveError Board -> PGN -> IO ()
printGame b pgn = printPGN pgn >> printBoard b
- where
- printBoard (Left e) = putStrLn $ show e
- printBoard (Right b) = putStr $ show b
- printPGN :: PGN -> IO ()
- printPGN pgn = do
- putStrLn $ site pgn ++ " " ++ date pgn ++ ": " ++ whitePlayer pgn ++ " vs. " ++ blackPlayer pgn
- putStrLn $ show $ result pgn
+printBoard (Left e) = putStrLn $ show e
+printBoard (Right b) = putStr $ show b
+
+printPGN :: PGN -> IO ()
+printPGN pgn = do
+ putStrLn $ site pgn ++ " " ++ date pgn ++ ": " ++ whitePlayer pgn ++ " vs. " ++ blackPlayer pgn
+ putStrLn $ show $ result pgn