m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/Abs.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Abs.hs')
-rw-r--r--Abs.hs27
1 files changed, 27 insertions, 0 deletions
diff --git a/Abs.hs b/Abs.hs
new file mode 100644
index 0000000..cfdd854
--- /dev/null
+++ b/Abs.hs
@@ -0,0 +1,27 @@
+module Abs where
+
+import Parser.AbsSchmim
+import Data.Map.Lazy
+
+type Env = Map Ident Val
+
+data Val
+ = VNum Integer
+ | VAbs Ident Type Env Exp
+ | VTr
+ | VFl
+ | VVrnt Ident Val Type
+ | VTpl [Val]
+ | VNil Type
+ | VCons Val Val
+ deriving (Eq, Ord, Read)
+
+instance Show Val where
+ show (VNum n) = show n
+ show (VAbs x t _ _) = "#(lambda " ++ (show x) ++ " : " ++ (show t) ++ ")"
+ show (VTr) = "true"
+ show (VFl) = "false"
+ show (VVrnt l v _) = "<" ++ (show l) ++ " " ++ (show v) ++ ">"
+ show (VTpl vs) = "{" ++ (show vs) ++ "}"
+ show (VNil t) = "nil"
+ show (VCons v1 v2) = "(cons " ++ (show v1) ++ " " ++ (show v2) ++ ")"