Map.agda 801 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. module Data.Map
  2. (Key : Set)
  3. where
  4. import Data.Bool
  5. import Data.Maybe
  6. open Data.Bool
  7. infix 40 _<_ _>_
  8. postulate
  9. _<_ : Key -> Key -> Bool
  10. _>_ : Key -> Key -> Bool
  11. x > y = y < x
  12. private
  13. data Map' (a : Set) : Set where
  14. leaf : Map' a
  15. node : Key -> a -> Map' a -> Map' a -> Map' a
  16. Map : Set -> Set
  17. Map = Map'
  18. empty : {a : Set} -> Map a
  19. empty = leaf
  20. {-
  21. insert : {a : Set} -> Key -> a -> Map a -> Map a
  22. insert k v leaf = node k v leaf leaf
  23. insert k v (node k' v' l r) =
  24. | k < k' => node k' v' (insert k v l) r
  25. | k > k' => node k' v' l (insert k v r)
  26. | otherwise node k' v l r
  27. -}
  28. open Data.Maybe
  29. {-
  30. lookup : {a : Set} -> Key -> Map a -> Maybe a
  31. lookup k leaf = nothing
  32. lookup k (node k' v l r) =
  33. | k < k' => lookup k l
  34. | k > k' => lookup k r
  35. | otherwise just v
  36. -}