git @ Cat's Eye Technologies Falderal / c860571
Make Formatter slightly more Haskellesque and slightly less crude. Chris Pressey 13 years ago
1 changed file(s) with 7 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
4646 testText <- readFile fileName
4747 lines <- return $ transformLines $ lines testText
4848 blocks <- return $ convertLinesToBlocks $ lines
49 outputText <- return $ formatBlocks blocks
49 outputText <- return $ formatBlocks (formatBlock) blocks
5050 putStr outputText
5151
52 formatBlocks [] = ""
53 formatBlocks ((Section sectionText):rest) =
54 sectionText ++ (formatBlocks rest)
55 formatBlocks ((Test literalText inputText expected):rest) =
56 literalText ++ inputText ++ (show expected) ++ (formatBlocks rest)
52 formatBlocks formatter blocks = foldl (++) "" (map (formatter) blocks)
53
54 formatBlock (Section sectionText) =
55 sectionText ++ "\n"
56 formatBlock (Test literalText inputText expected) =
57 literalText ++ "\n" ++ "| " ++ inputText ++ "\n> " ++ (show expected) ++ "\n"