1 Jul 2010 01:02
Re: Containers and strictness
Johan Tibell <johan.tibell <at> gmail.com>
2010-06-30 23:02:39 GMT
2010-06-30 23:02:39 GMT
On Thu, Jul 1, 2010 at 12:03 AM, Milan Straka <fox <at> ucw.cz> wrote:
Hi,I agree that my choice was not good enough. Johan Tibell also
> Milan Straka wrote:
> > I am working on improving containers performance and have written
> > a draft paper about it http://fox.ucw.cz/papers/containers/containers.pdf
>
> I am a bit surprised about the types chosen for HashSet and HashMap
> (section 5, p.9). Usually, hash-based containers are optimized for the case
> that the hash-buckets remain small. For that case, it's hard to imagine that
> the given types wouldn't be slower than the more straightforward types:
>
> data HashSet elem = HS (IntMap [elem])
> data HashMap key val = HM (IntMap [(key, val)])
>
> Others have suggested further improvements by using strict
> (unboxed?) tuples, a variant on lists that is strict and/or
> non-empty.
commented on this.
After suggestions by others I am thinking about
data Some elem = Single {-# UNPACK #-} !elem | More (Set elem)
or
data Some elem = Single {-# UNPACK #-} !elem | More {-# UNPACK #-} !elem (Some elem)
Unfortunately unpacking doesn't work for polymorphic fields (the new warning for ineffective unpack pragmas in GHC head should warn about this). Given this you might as well use a standard list.
Johan
_______________________________________________ Libraries mailing list Libraries <at> haskell.org http://www.haskell.org/mailman/listinfo/libraries
.
The problems start when all of these classes are linked to a single
Monad instance, and the 'fail' that has been put in it. So far, I had
thought that there was a way to have all common uses of Either
compatible with a single 'fail' (representing both non-local returns
and empty sums), so I've been arguing to keep a sufficiently
general Monad instance for Either. If you are certain that is not
possible, none of the mutually incompatible Monad instances
should go in base (mtl should simply use its own Either variant)!
> The fact we can't come up with a sensible 'fail' for it is not an
> indication of a problem with fail, or with either, but with simply
> assuming incorrectly that a non-local return must mean failure, we
> should have accepted what the type system was telling us and realized
> that we shouldnt be giving it a fail :).
>
> I do think we should make a dedicated failure monad though. It is also a
> useful thing.
As long as we have MonadPlus and MonadError instances for
Either, I assume that we've already decided to use Either for
both sums and failure. I'm not saying that could not be changed,
but if someone wants to use Either in ways that are not compatible
with these existing uses, why should everyone else have to adapt?
Claus
RSS Feed