30 lines
635 B
Haskell
30 lines
635 B
Haskell
{-# language PartialTypeSignatures #-}
|
|
{-# language OverloadedStrings #-}
|
|
|
|
module Main where
|
|
|
|
import System.Environment
|
|
import Data.Attoparsec.Text
|
|
import Data.Text.IO
|
|
import Data.Text
|
|
|
|
import Parse
|
|
import Process
|
|
|
|
printBW :: _ => ([Text], a) -> IO ()
|
|
printBW (ws, c) = do
|
|
let joined = Data.Text.intercalate " " ws
|
|
Data.Text.IO.putStr joined
|
|
Prelude.putStr ","
|
|
Prelude.print c
|
|
|
|
main :: IO ()
|
|
main = do
|
|
[filename] <- getArgs
|
|
txt <- Data.Text.IO.readFile filename
|
|
let result = parseOnly Parse.words txt
|
|
case result of
|
|
Right ls -> do
|
|
let result = process ls
|
|
mapM_ printBW result
|
|
Left err -> print err
|