reset password
Author Message
rabbott
Posts: 1649
Posted 10:19 Oct 23, 2016 |

I take my primary job to be to help you understand the material in this course. When we talk, my primary concern is to determine whether you understand something. That's not easy. I have known people who are good at saying many of the words they would say if they knew something but were simply repeating words they don't understand. So I often push to ensure myself that you really understand the material. 

One of the best ways to convince me you understand something is to explain it to me in simple terms, as if you were explaining it to a 10-year old. Use short sentences and as few pronouns as possible. Be simple, clear, and direct.

For example, here's how you might explain myUncurry.

First show your code.

myUncurry  :: (a -> b -> c) -> (a, b) -> c
myUncurry f = \(x, y) -> f x y

Then say something like the following.

  • myUncurry takes a function of two inputs as an argument. Point to both (a -> b -> c) and f and indicate that they refer to the input to myUncurry.

 

  • myUncurry produces a function as its output.

 

  • At this point you might re-write the type of myUncurry as: myUncurry  :: (a -> b -> c) -> ( (a, b) -> c ), emphasizing the extra parentheses.

 

  • Say that the extra parenetheses surround the function produced as output by myUncurry.

 

  • The extra parentheses show that the output function takes a pair (a, b) as input (you might also call this a tuple of two elements; either is ok) and produces a value of type c.

 

  • Point out the parallels and differences between the types of the input and output of myUncurry. They are both functions. But one is a function of two arguments of types a and b that produces an output of type c. The other is a function of a pair of type (a, b) that produces an output of type c.

 

  • The output function is expressed as a lambda function. ( Point to the lambda function \(x, y) -> f x y. )

 

  • The lambda function has one parameters, the pair (x, y). In its body the lambda function applies the function f that was the original argument to myUncurry to the two components of the input pair: f x y

 

  • To show that you really understand this, you might rewrite the lambda function as follows: \p -> f (fst p) (snd p). Then explain why this is the same as the original.

 

  • The overall effect is that the output of myUncurry is a function that computes the same function as the input function to myUncurry, but it accepts its two inputs as a single argument, wrapped as a pair.

 

That's quite a bit to say. But if you say all that, I'll be convinced that you understand myUncurry. If you don't say all that I may believe that you are skipping over some of the explanation because you don't understand it. I may then start asking about the parts that you skipped over.

Last edited by rabbott at 10:52 Oct 23, 2016.