summaryrefslogtreecommitdiff
path: root/IntMapClass.hs
diff options
context:
space:
mode:
Diffstat (limited to 'IntMapClass.hs')
-rw-r--r--IntMapClass.hs9
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)
51adapt_m :: (IntMap a -> x) -> IMap k a -> x 51adapt_m :: (IntMap a -> x) -> IMap k a -> x
52adapt_m f (IMap m) = f m 52adapt_m f (IMap m) = f m
53 53
54first 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
76lookupLT :: ( Coercible Int k, Coercible k Int ) => k -> IMap k a -> Maybe (k, a) 78lookupLT :: ( Coercible Int k, Coercible k Int ) => k -> IMap k a -> Maybe (k, a)
77lookupLT k m = fmap (first coerce) $ adapt_k_m (IntMap.lookupLT) k m 79lookupLT k m = fmap (first coerce) $ adapt_k_m (IntMap.lookupLT) k m
78 where first f (x,y) = (f x,y) 80lookupGT :: ( Coercible Int k, Coercible k Int ) => k -> IMap k a -> Maybe (k, a)
81lookupGT k m = fmap (first coerce) $ adapt_k_m (IntMap.lookupGT) k m
82lookupLE :: ( Coercible Int k, Coercible k Int ) => k -> IMap k a -> Maybe (k, a)
83lookupLE k m = fmap (first coerce) $ adapt_k_m (IntMap.lookupLE) k m
84lookupGE :: ( Coercible Int k, Coercible k Int ) => k -> IMap k a -> Maybe (k, a)
85lookupGE k m = fmap (first coerce) $ adapt_k_m (IntMap.lookupGE) k m