Your code is fine, you just need to specify all the arguments in the ghci prompt, for example
lookUp 'c' [('b','n'), ('c','q')]
Gotta give you a q.
He complains that he cannot show the function. Every time he says that this is not an instance of Show for something with → in, he complains that he cannot show the function. It can only display the result of using a function for some data.
When you give it some, but not all, of the data, Haskell interprets this as a new function that takes the next argument, therefore
lookUp 'c'
is a function that takes a list of pairs of characters and gives you a character. This is what he tried to show, but could not.
By the way, almost every time you get the error "There is no instance for ...", this is because you did something wrong with the arguments - missed some of them, put them in the wrong order. The compiler is trying to be helpful by suggesting you add an instance, but you probably just need to verify that you provided the record type of the arguments in the correct order.
Have fun learning Haskell!
source share