aboutsummaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorTom Smeding <tom.smeding@gmail.com>2020-07-23 20:15:15 +0200
committerTom Smeding <tom.smeding@gmail.com>2020-07-23 20:15:15 +0200
commit39ea4ac3a4b7663882a83f2ada43c8238f087d9b (patch)
tree70b28d7f0bd301f8eb912837b126956ecdaa1ca3 /main
parentbc52411ae2ed26cab1d5086ae6df68f23ebbd052 (diff)
Use Pretty for errors and expressions
Diffstat (limited to 'main')
-rw-r--r--main/Main.hs12
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