diff options
Diffstat (limited to 'main/Main.hs')
-rw-r--r-- | main/Main.hs | 12 |
1 files changed, 7 insertions, 5 deletions
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 "<stdin>" case combined context (read source) of - Right prog -> print prog - Left err -> die (show err) + Right prog -> pprint prog + Left err -> die err |