From 39ea4ac3a4b7663882a83f2ada43c8238f087d9b Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Thu, 23 Jul 2020 20:15:15 +0200 Subject: Use Pretty for errors and expressions --- main/Main.hs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'main') diff --git a/main/Main.hs b/main/Main.hs index 58e475c..3216833 100644 --- a/main/Main.hs +++ b/main/Main.hs @@ -4,6 +4,8 @@ import System.Exit import qualified CC.Parser import qualified CC.Typecheck + +import CC.Pretty import CC.Types @@ -13,10 +15,10 @@ import CC.Types type Pass a b = Context -> a -> Either String b -pass :: (Read a, Show b, Show e) => (Context -> a -> Either e b) -> Pass a b -pass f ctx a = either (Left . show) Right (f ctx a) +pass :: (Read a, Show b, Pretty e) => (Context -> a -> Either e b) -> Pass a b +pass f ctx a = either (Left . pretty) Right (f ctx a) -passJoin :: (Read a, Show b, Read b, Show c) => Pass a b -> Pass b c -> Pass a c +passJoin :: (Read a, Show c) => Pass a b -> Pass b c -> Pass a c passJoin f1 f2 ctx a = f1 ctx a >>= f2 ctx main :: IO () @@ -29,5 +31,5 @@ main = do source <- getContents let context = Context "" case combined context (read source) of - Right prog -> print prog - Left err -> die (show err) + Right prog -> pprint prog + Left err -> die err -- cgit v1.2.3-70-g09d2