[Haskell-beginners] Understanding Haskell Map.lookup Example in LYH

Olumide 50295 at web.de
Mon Dec 14 12:36:49 UTC 2015


Hello Haskellers!

I'd appreciate help understanding the origin of the extra 'map' in 
'Map.lookup lockerNumber map', from the following example taken from 
chapter 8 of "Learn You a Haskell for Great Good"
http://learnyouahaskell.com/making-our-own-types-and-typeclasses#type-synonyms

lockerLookup :: Int -> LockerMap -> Either String Code
lockerLookup lockerNumber map =
     case Map.lookup lockerNumber map of
         Nothing -> Left $ "Locker number " ++ show lockerNumber ++ " 
doesn't exist!"
         Just (state, code) -> if state /= Taken
                                 then Right code
                                 else Left $ "Locker " ++ show 
lockerNumber ++ " is already taken!"

Regards,

- Olumide


More information about the Beginners mailing list