DMG Forums | Haskell Project Hints
DMG Forums >> 4th Semester >> CSEN 403 - Concepts of Programming Languages >> Haskell Project Hints
Haskell Project Hints
Author Topic

GUC Faculty

Join Date: 9/9/2009
Posts: 6

Posted: 5/7/2010 12:19:00 PM

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.

GUC Faculty

Join Date: 9/9/2009
Posts: 6

Posted: 5/7/2010 12:21:13 PM

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).


Join Date: 10/15/2008
Posts: 1

Posted: 5/10/2010 11:58:18 PM

In the first part of the project Are we going to define the datatype like the one we did it in the lab or not? Sorry for posting the code I didn't know, but I just want to give an example. Thanks a lot for the note and for your concern.

GUC Faculty

Join Date: 9/9/2009
Posts: 6

Posted: 5/11/2010 9:20:09 AM

Please note that you are NOT allowed to post any code here. You can only post questions.