From ea5647fe44731865726d910973dcc58d83ad6cc5 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Mon, 10 Mar 2014 21:36:07 +1100 Subject: UnlambdaTerms now Show correctly --- Unlambda/Interpreter.hs | 2 -- Unlambda/Parser.hs | 23 +++++++++++++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Unlambda/Interpreter.hs b/Unlambda/Interpreter.hs index e5a442b..c9820f0 100644 --- a/Unlambda/Interpreter.hs +++ b/Unlambda/Interpreter.hs @@ -77,5 +77,3 @@ apply firstTerm secondTerm = Compare c -> return I --placeholder - Continuation cont -> return I --placeholder - diff --git a/Unlambda/Parser.hs b/Unlambda/Parser.hs index 7e578ad..948211d 100644 --- a/Unlambda/Parser.hs +++ b/Unlambda/Parser.hs @@ -19,9 +19,28 @@ data UnlambdaTerm = S | K | I | V | R | D | C | E | Bar | Reed | Kpartial UnlambdaTerm | Spartial UnlambdaTerm | Sapp UnlambdaTerm UnlambdaTerm - | Continuation UnlambdaTerm | Promise UnlambdaTerm - deriving (Eq, Show) + deriving (Eq) + + +instance Show UnlambdaTerm where + show S = "s" + show K = "k" + show I = "i" + show V = "v" + show R = "r" + show D = "d" + show C = "c" + show E = "e" + show Bar = "|" + show Reed = "@" + show (Dot x) = ['.', x] + show (Compare x) = ['?', x] + show (App x y) = "`" ++ (show x) ++ (show y) + show (Kpartial x) = "`k" ++ (show x) + show (Spartial x) = "`s" ++ (show x) + show (Sapp x y) = "``s" ++ (show x) ++ (show y) + show (Promise x) = "`d" ++ (show x) -- cgit