diff options
Diffstat (limited to 'IntMapClass.hs')
-rw-r--r-- | IntMapClass.hs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/IntMapClass.hs b/IntMapClass.hs index 9ab83db..28ae5ba 100644 --- a/IntMapClass.hs +++ b/IntMapClass.hs | |||
@@ -51,6 +51,8 @@ adapt_m_m f m = adapt_m (adapt_m f m) | |||
51 | adapt_m :: (IntMap a -> x) -> IMap k a -> x | 51 | adapt_m :: (IntMap a -> x) -> IMap k a -> x |
52 | adapt_m f (IMap m) = f m | 52 | adapt_m f (IMap m) = f m |
53 | 53 | ||
54 | first f (x,y) = (f x,y) | ||
55 | |||
54 | 56 | ||
55 | (!) :: Coercible k Int => IMap k a -> k -> a | 57 | (!) :: Coercible k Int => IMap k a -> k -> a |
56 | (!) = adapt_m_k (IntMap.!) | 58 | (!) = adapt_m_k (IntMap.!) |
@@ -75,4 +77,9 @@ findWithDefault a = adapt_k_m (IntMap.findWithDefault a) | |||
75 | 77 | ||
76 | lookupLT :: ( Coercible Int k, Coercible k Int ) => k -> IMap k a -> Maybe (k, a) | 78 | lookupLT :: ( Coercible Int k, Coercible k Int ) => k -> IMap k a -> Maybe (k, a) |
77 | lookupLT k m = fmap (first coerce) $ adapt_k_m (IntMap.lookupLT) k m | 79 | lookupLT k m = fmap (first coerce) $ adapt_k_m (IntMap.lookupLT) k m |
78 | where first f (x,y) = (f x,y) | 80 | lookupGT :: ( Coercible Int k, Coercible k Int ) => k -> IMap k a -> Maybe (k, a) |
81 | lookupGT k m = fmap (first coerce) $ adapt_k_m (IntMap.lookupGT) k m | ||
82 | lookupLE :: ( Coercible Int k, Coercible k Int ) => k -> IMap k a -> Maybe (k, a) | ||
83 | lookupLE k m = fmap (first coerce) $ adapt_k_m (IntMap.lookupLE) k m | ||
84 | lookupGE :: ( Coercible Int k, Coercible k Int ) => k -> IMap k a -> Maybe (k, a) | ||
85 | lookupGE k m = fmap (first coerce) $ adapt_k_m (IntMap.lookupGE) k m | ||