From bdc72de514f63440a634d011faedfbeef770ed1f Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Sun, 13 May 2018 19:51:07 +0200 Subject: Initial commit --- Abs.hs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Abs.hs (limited to 'Abs.hs') 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) ++ ")" -- cgit v1.2.3