Safe Haskell | Safe |
---|---|

Language | Haskell2010 |

## Synopsis

- data IMap a
- data Run a = Run {}
- empty :: IMap a
- null :: IMap a -> Bool
- singleton :: Int -> Run a -> IMap a
- insert :: Int -> Run a -> IMap a -> IMap a
- delete :: Int -> Run ignored -> IMap a -> IMap a
- restrict :: Int -> Run ignored -> IMap a -> IMap a
- lookup :: Int -> IMap a -> Maybe a
- splitLE :: Int -> IMap a -> (IMap a, IMap a)
- intersectionWith :: (a -> b -> c) -> IMap a -> IMap b -> IMap c
- mapMaybe :: (a -> Maybe b) -> IMap a -> IMap b
- addToKeys :: Int -> IMap a -> IMap a
- unsafeUnion :: IMap a -> IMap a -> IMap a
- fromList :: [(Int, Run a)] -> IMap a
- unsafeRuns :: IMap a -> IntMap (Run a)
- unsafeToAscList :: IMap a -> [(Int, Run a)]

# Documentation

Semantically, `IMap`

and `IntMap`

are identical; but `IMap`

is more
efficient when large sequences of contiguous keys are mapped to the same
value.

`Run n a`

represents `n`

copies of the value `a`

.

## Instances

Functor Run Source # | |

Foldable Run Source # | |

Defined in Data.IMap fold :: Monoid m => Run m -> m # foldMap :: Monoid m => (a -> m) -> Run a -> m # foldr :: (a -> b -> b) -> b -> Run a -> b # foldr' :: (a -> b -> b) -> b -> Run a -> b # foldl :: (b -> a -> b) -> b -> Run a -> b # foldl' :: (b -> a -> b) -> b -> Run a -> b # foldr1 :: (a -> a -> a) -> Run a -> a # foldl1 :: (a -> a -> a) -> Run a -> a # elem :: Eq a => a -> Run a -> Bool # maximum :: Ord a => Run a -> a # | |

Traversable Run Source # | |

Eq a => Eq (Run a) Source # | |

Ord a => Ord (Run a) Source # | |

Read a => Read (Run a) Source # | |

Show a => Show (Run a) Source # | |

restrict :: Int -> Run ignored -> IMap a -> IMap a Source #

Given a range of keys (as specified by a starting key and a length for
consistency with other functions in this module), restrict the map to keys
in that range. `restrict k r m`

is equivalent to ```
intersectionWith const m
(insert k r empty)
```

but potentially more efficient.

splitLE :: Int -> IMap a -> (IMap a, IMap a) Source #

`splitLE n m`

produces a tuple `(le, gt)`

where `le`

has all the
associations of `m`

where the keys are `<= n`

and `gt`

has all the
associations of `m`

where the keys are `> n`

.

addToKeys :: Int -> IMap a -> IMap a Source #

Increment all keys by the given amount. This is like
`mapKeysMonotonic`

, but restricted to partially-applied addition.

unsafeUnion :: IMap a -> IMap a -> IMap a Source #

This function is unsafe because it assumes there is no overlap between its
arguments. That is, in the call `unsafeUnion a b`

, the caller must guarantee
that if `lookup k a = Just v`

then `lookup k b = Nothing`

and vice versa.