summaryrefslogtreecommitdiff
path: root/IntMapClass.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2014-08-12 16:43:53 -0400
committerjoe <joe@jerkface.net>2014-08-12 16:43:53 -0400
commit524dee47806e54c77db56755fc0fdac932b0e887 (patch)
tree0050ff20e110eacf674c2c16d93116db661f0581 /IntMapClass.hs
parentb1a9f8026ec205fbce84680a7e2a7847c49c0098 (diff)
more IntMapClass and special t test-building script
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