From 559712d25763a79dd0b668f76502538386d03a68 Mon Sep 17 00:00:00 2001 From: Erik Post Date: Fri, 9 Aug 2019 22:55:20 +0200 Subject: [PATCH] Prettify top-level output. #71 --- cli/Main.hs | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/cli/Main.hs b/cli/Main.hs index 622bb27..c18fbdc 100644 --- a/cli/Main.hs +++ b/cli/Main.hs @@ -23,12 +23,25 @@ module Main where import Language.CQL import System.Environment - main :: IO () -main = do args <- getArgs - w <- mapM readFile args - _ <- mapM (putStrLn . f' . runProg) w - return () - where f' (Left x) = x - f' (Right (_,t,c)) = show t ++ "\n\n-------------------\n\n" ++ show c +main = do + args <- getArgs + src <- mapM readFile args + _ <- mapM (putStrLn . showResult . runProg) src + return () + where + showResult r = case r of + Right (_, types, env) -> + "////////////////////////////////////////////////////////////////////////////////\n" ++ + "// types //\n" ++ + "////////////////////////////////////////////////////////////////////////////////\n" ++ + "\n" ++ + "\n" ++ + show types ++ + "////////////////////////////////////////////////////////////////////////////////\n" ++ + "// environment //\n" ++ + "////////////////////////////////////////////////////////////////////////////////\n" ++ + "\n" ++ + show env + Left err -> err