Executing Parsed function calls in Haskell

98 views Asked by At

First i want to say I'm a newbie in Haskell. Here's my problem: For a school project I need to be able to parse and interprate and execute a fucntion call. This call needs to be able to execute a function already defined in haskell.
Parsing the call works, but i have no idea how to execute the function because the amount of arguments and type is unkown.

Here is how i represent my data

type Name = String
type Cond = Expr
data Expr
  = Num Int  
  | Boolean Bool
  | BinOp Op Expr Expr
  | Var Name 
  deriving (Eq, Ord, Show)
data Stmnt 
  = Call Name [Expr]
  | If Cond [Stmnt] [Stmnt]
  | While Cond [Stmnt]
  | VarDef Name Expr
  deriving (Eq, Ord, Show)

This is a part of my interpeter. And it is with the implementation of funcall that I need help.

data Value = FineInt Int 
           | FineBool Bool
           | FineFun ([Value] -> Value)
-- The enviroment keeps track of variables in the program          
type Env = [(Name,Value)]
-- A state that takes an enviroment
type StEnv = State Env

evalstm :: Stmnt -> StEnv ()
evalstm (Call name exprs)  = funcall name exprs

-- funcall name exprs = ?
0

There are 0 answers