<subject change>
On Sun, Sep 29, 2013 at 3:31 AM, Mike Izbicki
<mike@izbicki.me> wrote:
I've got a Partitionable class that I've been using for this purpose:
Mike -- Neat, that's a cool library!
Edward -- ideally, where in the standard libraries should the Partitionable comonoid go?
Btw, I'm not sure what the ideal return type for comappend is, given that it needs to be able to "bottom out". Mike, our partition function's list return type seems more reasonable. Or maybe something simple would be this:
class Partitionable t where
partition :: t -> Maybe (t,t)
That is, at some point its not worth splitting and returns Nothing, and you'd better be able to deal with the 't' directly.
So what I really want is for the containers package to please get some kind of Partitionable instances! Johan & others, I would be happy to provide a patch if the class can be agreed on. This is important because currently the balanced tree structure of Data.Set/Map is an amazing and beneficial property that is not exposed at all through the API.
For example, it would be great to have a parallel traverse_ for Maps and Sets in the Par monad. The particular impetus is that our new and enhanced Par monad makes extensive use of Maps and Sets, both the pure, balanced ones, and lockfree/inplace ones based on concurrent skip lists:
Alternatively, it would be ok if there were a "Data.Map.Internal" module that exposed the Bin/Tip, but I assume people would rather have a clean Partitionable instance...
Best,
-Ryan