module Zinza.Value where
import qualified Data.Map.Strict as M
import Zinza.Errors
import Zinza.Type
import Zinza.Var
data Value
= VBool Bool
| VString String
| VList [Value]
| VRecord (M.Map Var Value)
| VFun (Value -> Either RuntimeError Value)
valueType :: Value -> Ty
valueType (VBool _) = TyBool
valueType (VString _) = TyString Nothing
valueType (VList []) = TyList Nothing tyUnit
valueType (VList (v:_)) = TyList Nothing (valueType v)
valueType (VRecord m) = TyRecord (fmap (\v -> ("", valueType v)) m)
valueType (VFun _) = TyFun tyUnit tyUnit