summaryrefslogtreecommitdiff
path: root/Unlambda/Parser.hs
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2014-03-12 23:16:10 +1100
committerJed Barber <jjbarber@y7mail.com>2014-03-12 23:16:10 +1100
commit0649a52fe819a8a98b38d2c8d9c7a10af0597461 (patch)
tree7d8276d48dea33b769d069d6d090e14b1fefc507 /Unlambda/Parser.hs
parentc71774e0dfd81df81f2de5a7f2c9a5f703bac9b2 (diff)
Continuations now working, but @,|,? removed temporarily
Diffstat (limited to 'Unlambda/Parser.hs')
-rw-r--r--Unlambda/Parser.hs26
1 files changed, 25 insertions, 1 deletions
diff --git a/Unlambda/Parser.hs b/Unlambda/Parser.hs
index 948211d..ec604cf 100644
--- a/Unlambda/Parser.hs
+++ b/Unlambda/Parser.hs
@@ -7,6 +7,8 @@ module Unlambda.Parser (
import Control.Applicative( some )
+import Control.Monad.Trans.Cont
+import Control.Monad.IO.Class
import Data.Either
import Text.ParserCombinators.Parsec
@@ -20,7 +22,28 @@ data UnlambdaTerm = S | K | I | V | R | D | C | E | Bar | Reed
| Spartial UnlambdaTerm
| Sapp UnlambdaTerm UnlambdaTerm
| Promise UnlambdaTerm
- deriving (Eq)
+ | Continuation (UnlambdaTerm -> ContT UnlambdaTerm IO UnlambdaTerm)
+
+
+instance Eq UnlambdaTerm where
+ S == S = True
+ K == K = True
+ I == I = True
+ V == V = True
+ R == R = True
+ D == D = True
+ C == C = True
+ E == E = True
+ Bar == Bar = True
+ Reed == Reed = True
+ Dot x == Dot y = x == y
+ Compare x == Compare y = x == y
+ App a b == App x y = a == x && b == y
+ Kpartial x == Kpartial y = x == y
+ Spartial x == Spartial y = x == y
+ Sapp a b == Sapp x y = a == x && b == y
+ Promise x == Promise y = x == y
+ _ == _ = False
instance Show UnlambdaTerm where
@@ -41,6 +64,7 @@ instance Show UnlambdaTerm where
show (Spartial x) = "`s" ++ (show x)
show (Sapp x y) = "``s" ++ (show x) ++ (show y)
show (Promise x) = "`d" ++ (show x)
+ show (Continuation _) = "<cont>"