m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/Abs.hs
blob: cfdd8548686f7d17313e6411e6b6008906ab4ad1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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) ++ ")"