instance Show Data.Map? (was Re: [Haskell] Data.Map missing keysFM_GE, eltsFM_GE?)

S. Alexander Jacobson alex at
Mon Feb 21 17:06:05 EST 2005

Ok, thanks.  I also notice that Data.Map derives Show, but not Read
and that the shown format is slightly annoying to parse because it 
creates this new pseudo-operator (:=).

Given that you can't hide instance declarations, it would be better 
either not to implement Show at all, to implement it as 
(show.assocs), or to provide a Read instance.

Any hope of the above, or do I need to refactor my code not to use 
(Read,Show) around Data.Map?


S. Alexander Jacobson tel:917-770-6565

On Mon, 21 Feb 2005, Tomasz Zielonka wrote:

> On Mon, Feb 21, 2005 at 02:39:54PM -0500, S. Alexander Jacobson wrote:
>> Data.FiniteMap has functions keysFM_GE and eltsFM_GE which return the
>> keys or elts of pairs greater than or equal to the provided key.
>> These functions do not appear to be in the new Data.Map.
>> Is this intentional?
> There is
>    splitLookup :: (Ord k) =>
>                   k
>                   -> Data.Map.Map k a
>                   -> (Data.Map.Map k a, Maybe a, Data.Map.Map k a)
> and
>    toAscList :: Data.Map.Map k a -> [(k, a)]
> so you can write keysFM_GE and eltsFM_GE yourself, for example:
>  eltsFM_GE k m = maybe [] return eq ++ snd (toAscList ge)
>    where
>      (_, eq, ge) = splitLookup k m in
> Best regards
> Tomasz

More information about the Haskell mailing list