
On 02/18/11 18:21, Edward Kmett wrote:
On Fri, Feb 18, 2011 at 3:32 PM, Johan Tibell
wrote: On Thu, Feb 17, 2011 at 4:51 PM, Johan Tibell
wrote: My current thinking is to provide lazy and strict versions in different modules. The two modules could still share the same data type. The question is, what should be the default? Haskell is a lazy language but the most common use cases for maps are strict (e.g. a map from strings to integer counters).
What about class instances? With a shared data type we can only provide one set of instances, probably the lazy ones. Assuming we used to separate data types, can we even define instances for all common classes (e.g. Functor, Foldable, Monoid) or will the strict versions violate some of the laws for these classes?
Hrmm, the strict version will violate the laws for Functor:
(fmap (const 12) . fmap error) /= fmap (const 12 . error)
That's an issue, though. It means you can't use a Map that tries to keep its values always strict if you want to use class Functor with it. *Even if* it's a separate type in Data.SomeMap.Strict. (Unless you're willing to break the law in the presence of _|_ values.) -Isaac