Reputation: 93
I have this homework question that I don't understand. I'm not sure where to start or what the purpose of this question is as to what it's suppose to do. If anyone could help that'd be great as I am new to Haskell. Below is the question:
identity x = x. Your definition must have the form identity = e
where e mentions *only* ap and proj and parentheses.
ap f g x = f x (g x)
proj x y = x
identity :: a -> a
identity =
What is this above identity
function suppose to accomplish or do after it's given an input?
thanks!
Upvotes: 2
Views: 101
Reputation: 2223
One way is identity = (ap proj proj)
. That makes identity x = proj x (proj x)
here (proj x)
is a function but that does not matter as it is thrown away, giving you the equality identity x = proj x _ = x
.
Upvotes: 0
Reputation: 153132
The identity function returns its input unchanged, as given by the homework question's specification that identity x = x
.
Upvotes: 4