Question: This is question 2: 2 [32pts] Type Inference In this problem you will apply the Hindley-Milner type inference algorithm we discussed in class to figure

 This is question 2: 2 [32pts] Type Inference In this problemyou will apply the Hindley-Milner type inference algorithm we discussed in class

This is question 2:

to figure out the type of two Haskell declarations. For both, you

2 [32pts] Type Inference In this problem you will apply the Hindley-Milner type inference algorithm we discussed in class to figure out the type of two Haskell declarations. For both, you must go through the five steps: creating the parse trees, assigning type variables, generating constraints, solving the constraints, and finally circling your final type answer (if no type error was encountered). 2.2[18pts] Infer the type of foldl: foldl f acc [] =acc foldl f acc (x:xs)= foldl f(faccx) xs 1. [3pts] Consider the same code snippet but, written in Haskell: letx=\yy+1inletx=(\z\yy+(z2))xinx2 What happens when this expression is evaluated? (Run the code with GHCi.) Briefly explain why this behavior is different from its JavaScript counterpart. 2 [32pts] Type Inference In this problem you will apply the Hindley-Milner type inference algorithm we discussed in class to figure out the type of two Haskell declarations. For both, you must go through the five steps: creating the parse trees, assigning type variables, generating constraints, solving the constraints, and finally circling your final type answer (if no type error was encountered). 2.2[18pts] Infer the type of foldl: foldl f acc [] =acc foldl f acc (x:xs)= foldl f(faccx) xs 1. [3pts] Consider the same code snippet but, written in Haskell: letx=\yy+1inletx=(\z\yy+(z2))xinx2 What happens when this expression is evaluated? (Run the code with GHCi.) Briefly explain why this behavior is different from its JavaScript counterpart

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!