This question is already solved, it is a mapping from a String to a "Maybe a", with empty,insert,lookup functions as defined below, i'm unable to understand the solution.
The code:
type Map a = String -> Maybe a
empty :: Map a
empty = \x -> Nothing
insert :: (String, a) -> Map a -> Map a
insert (s, a) m = \x -> if x == s then Just a else m x
lookup :: String -> Map a -> Maybe a
lookup x m = m x
empty and lookup i think i understand.
insert however is puzzling to me,the lambda inside it i don't understand, how is x used in the equality when it is never taken as a parameter, x is from what i can see is a String, but it isn't given a value anywhere.
what would be the resulting function from insert ("foo", 61) empty how would it be evaluated, and what does x represent?
also why would a line like this work and return "Just 61"
lookup "foo" (insert ("foo", 61) empty)