From 524dee47806e54c77db56755fc0fdac932b0e887 Mon Sep 17 00:00:00 2001 From: joe Date: Tue, 12 Aug 2014 16:43:53 -0400 Subject: more IntMapClass and special t test-building script --- IntMapClass.hs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'IntMapClass.hs') 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) adapt_m :: (IntMap a -> x) -> IMap k a -> x adapt_m f (IMap m) = f m +first f (x,y) = (f x,y) + (!) :: Coercible k Int => IMap k a -> k -> a (!) = adapt_m_k (IntMap.!) @@ -75,4 +77,9 @@ findWithDefault a = adapt_k_m (IntMap.findWithDefault a) lookupLT :: ( Coercible Int k, Coercible k Int ) => k -> IMap k a -> Maybe (k, a) lookupLT k m = fmap (first coerce) $ adapt_k_m (IntMap.lookupLT) k m - where first f (x,y) = (f x,y) +lookupGT :: ( Coercible Int k, Coercible k Int ) => k -> IMap k a -> Maybe (k, a) +lookupGT k m = fmap (first coerce) $ adapt_k_m (IntMap.lookupGT) k m +lookupLE :: ( Coercible Int k, Coercible k Int ) => k -> IMap k a -> Maybe (k, a) +lookupLE k m = fmap (first coerce) $ adapt_k_m (IntMap.lookupLE) k m +lookupGE :: ( Coercible Int k, Coercible k Int ) => k -> IMap k a -> Maybe (k, a) +lookupGE k m = fmap (first coerce) $ adapt_k_m (IntMap.lookupGE) k m -- cgit v1.2.3