Skip to content

Commit

Permalink
Add wrapping/unwrapping of IntMaps and IntSets.
Browse files Browse the repository at this point in the history
  • Loading branch information
michalt committed May 17, 2011
1 parent 0f5ed3e commit 3e1c0eb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Data/EnumMap.hs
Expand Up @@ -18,6 +18,10 @@
module Data.EnumMap
( EnumMap

-- * Wrapping/unwrapping
, intMapToEnumMap
, enumMapToIntMap

-- * Operators
, (!)
, (\\)
Expand Down Expand Up @@ -165,6 +169,18 @@ instance (Enum k, Read k, Read a) => Read (EnumMap k a) where
list <- readPrec
return (fromList list)

--
-- Conversion to/from 'IntMap'.
--

-- | Wrap 'IntMap'.
intMapToEnumMap :: IntMap a -> EnumMap k a
intMapToEnumMap = EnumMap

-- | Unwrap 'IntMap'.
enumMapToIntMap :: EnumMap k a -> IntMap a
enumMapToIntMap = unWrap

--
-- A few useful functions used through the module. Not exported.
--
Expand Down
16 changes: 16 additions & 0 deletions Data/EnumSet.hs
Expand Up @@ -17,6 +17,10 @@
module Data.EnumSet
( EnumSet

-- * Wrapping/unwrapping
, intSetToEnumSet
, enumSetToIntSet

-- * Operators
, (\\)

Expand Down Expand Up @@ -99,6 +103,18 @@ instance (Enum e, Read e) => Read (EnumSet e) where
list <- readPrec
return (fromList list)

--
-- Conversion to/from 'IntSet'.
--

-- | Wrap 'IntSet'.
intSetToEnumSet :: IntSet -> EnumSet e
intSetToEnumSet = EnumSet

-- | Unwrap 'IntSet'.
enumSetToIntSet :: EnumSet e -> IntSet
enumSetToIntSet = unWrap

--
-- A few useful functions used through the module; not exported.
--
Expand Down

0 comments on commit 3e1c0eb

Please sign in to comment.