Created
July 31, 2012 11:55
-
-
Save joker1007/3216436 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module MyMaybe where | |
data MyMaybe a = MyJust a | MyNothing deriving Show | |
instance Monad MyMaybe where | |
return m = MyJust m | |
(>>=) m f = case m of | |
MyJust a -> f a | |
MyNothing -> MyNothing | |
mylookup :: (Eq k) => k -> [(k, v)] -> MyMaybe v | |
mylookup k ms = foldr (\(key, v) acc -> if k == key then MyJust v else acc) MyNothing ms |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment