Bohtvaroh

Map on Closures in Haskell

Dec 20th, 2011
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. type Dict a b = a -> Maybe b
  2.  
  3. empty :: Dict a b
  4. empty _ = Nothing
  5.  
  6. add :: (Eq a) => Dict a b -> a -> b -> Dict a b
  7. add dict key value = \key' -> if key' == key then Just value else dict key'
  8.  
  9. find :: Dict a b -> a -> Maybe b
  10. find dict key = dict key
Advertisement
Add Comment
Please, Sign In to add comment