Archived
1
Fork 0
This repository has been archived on 2025-04-09. You can view files and clone it, but cannot push or open issues or pull requests.
word-parse/app/Main.hs
2020-11-16 10:32:56 +01:00

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