DMG Forums | Haskell Project Hints
DMG Forums >> 4th Semester >> CSEN 403 - Concepts of Programming Languages >> Haskell Project Hints
Haskell Project Hints
Author Topic
yasmine.magdi@guc.edu.eg

GUC Faculty

Join Date: 9/9/2009
Posts: 6

Posted: 5/11/2010 9:17:01 AM

The first part of the project asks you to define datatypes for variables, arithemtic expressions, boolean expressions, if-then-else statements, guarded expressions and functions. In this part, you will only be defining datatypes for those things, such that whenever we need to express any of those statements we will be able to do that using those datatypes. No evaluations is required in this part, just syntactic representations for how any function should look like.


yasmine.magdi@guc.edu.eg

GUC Faculty

Join Date: 9/9/2009
Posts: 6

Posted: 5/11/2010 9:17:54 AM

Concerning the eval function, An example for calls to that function is:

eval "f_var" [1,2,3] [f_var x y z = y]

eval "f_fun" [1,4,2] [(f_fun x y z = f_bool2 x y z),
(f_bool2 x y z = (y>=x) || (y=<z) || (x==y))]

In the first case, we want to call the function with the name "f_var". Thus, the arguments to the eval function is:

1. The name of the function to be evaluated "f_var"

2. The values of the arguments to this function. The list above indicates that the binding for the first argument to the function (which is the variable 'x') will be 1, the binding to the second one (which is the variable 'y') will be 2 and the binding to the third one (which is the variable 'z') will be 3.

3. Given only the first two arguments, you will not be able to evaluate the function, since you do not yet know the body of the function. The third argument acts as if it is the haskell script (.hs file) in which the functions are defined. This list is a list of functions. To evaluate the function "f_var", you have to find its body using this third parameter. It is a list of functions, since the function that you need to evaluate may have a call to another function.
NOTE THAT: The functions in this list (The third argument to eval) will not be written in Haskell syntax as represented here, but will be written using whatever datatype you define for the function (the datatype defined in part A).

RenewSession