Re: Announce: EnumMap-0.0.1
Pardon my asking, but are fromEnum and toEnum guaranteed to preserve order on types like Double? I'd like to see a Double-backed Patricia tree map, but are we certain that EnumMap as presented will behave properly on such types? Louis Wasserman wasserman.louis@gmail.com
Double seems to truncate to Int while values outside of the bounds go to zero. Obviously there would be no way to have a one to one mapping as Double is often in excess of 64 bits while Int is often 32 bits. These recent questions are really more about knowing the tool (library) you are using. Double can't be used as a key in IntMat, but it can now be used as a key in EnumMap - if it works for your needs then great! Thomas On Mon, Aug 10, 2009 at 10:37 AM, Louis Wasserman<wasserman.louis@gmail.com> wrote:
Pardon my asking, but are fromEnum and toEnum guaranteed to preserve order on types like Double? I'd like to see a Double-backed Patricia tree map, but are we certain that EnumMap as presented will behave properly on such types?
Louis Wasserman wasserman.louis@gmail.com
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
I'm not exactly sure what you mean by preserve order, but no, Doubles would not behave as expected in an EnumMap because fromEnum for Doubles just truncates: fromEnum (2.0 :: Double) == 2 fromEnum (2.5 :: Double) == 2 However I think that is more an issue with the Enum instances than with EnumMap. I really don't think Double should be an instance of Enum. (or if it is, it should actually _enumerate_ the values) It's basically just there for the list comprehension syntax. take 5 [1.0 ..] :: [Double] == [1.0,2.0,3.0,4.0,5.0] But I feel like that would be better handled with Num instances or something, or with a separate typeclass. - Job On Mon, Aug 10, 2009 at 1:37 PM, Louis Wasserman <wasserman.louis@gmail.com>wrote:
Pardon my asking, but are fromEnum and toEnum guaranteed to preserve order on types like Double? I'd like to see a Double-backed Patricia tree map, but are we certain that EnumMap as presented will behave properly on such types?
Louis Wasserman wasserman.louis@gmail.com
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (3)
-
Job Vranish -
Louis Wasserman -
Thomas DuBuisson