{-# LANGUAGE InstanceSigs #-}

module AST where

import Control.Monad.Reader (Reader)

data Exp
  = Const Val
  | Var Var
  | App Exp Exp
  | Lambda Var Exp
  | Cond Exp Exp Exp
  | LetRec Var Var Exp Exp
  | Let Var Exp Exp
  | Pair Exp Exp
  deriving (Show)

type Var = String

data Val
  = ValBool Bool
  | ValInt Int
  | ValString String
  | ValFun (Val -> Cont -> Val)
  | ValPair (Val,Val)

type Cont = Val -> Val

instance Show Val where
  show :: Val -> String
  show (ValBool b) = "ValBool " ++ show b
  show (ValInt i) = "ValInt " ++ show i
  show (ValString s) = "ValString " ++ show s
  show (ValFun _) = "ValFun <function>"
  show (ValPair v) = "ValPair (" ++ show (fst v) ++ ", " ++ show (snd v) ++ ")"

type Env = [(Var, Val)]