[Haskell-cafe] Data.EnumMap ?

Johannes Waldmann waldmann at imn.htwk-leipzig.de
Tue Mar 31 17:42:20 UTC 2015

Dear Cafe,

in containers, we have Data.IntMap/IntSet .
Because of the underlying implementation (patricia trees),
keys/elements indeed have to be Int (we need their bits).

This is a conflict with type-safety: I try to avoid Int,
and use some  newtype T = T Int  instead.
E.g., I want to distinguish several different indices
for the same structure, like row and column numbers
in (sparse) matrices, or vertices in bipartite graphs.

So, I made these trivial wrappers EnumMap and EnumSet:

Is this reasonable (do from/toEnum really have zero cost)?
Would this be a useful addition to containers?

- J.W.

More information about the Haskell-Cafe mailing list