Answered step by step
Verified Expert Solution
Question
1 Approved Answer
2 [32pts] Type Inference 2.2 [18pts] Infer the type of foldl: In this problem you will apply the Hindley-Milner type inference algorithm we discussed in
2 [32pts] Type Inference 2.2 [18pts] Infer the type of foldl: In this problem you will apply the Hindley-Milner type inference algorithm we discussed in class to figure out foldl f acc []=acc the type of two Haskell declarations. For both, you must go through the five steps: creating the parse trees, foldl f acc (x:xs)= foldl f(faccx)xs assigning type variables, generating constraints, solving the constraints, and finally circling your final type answer (if no type error was encountered). 2.1 [14pts] Infer the type of reverse: reverse[]reverse(x:xs)=[=reversexs+[x] 3 Variable Bindings and Closures [3pts] Recall HW03 Problem 1. 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started