SAFE: a Foldable proposal

Thomas Tuegel ttuegel at
Fri Feb 26 02:31:30 UTC 2016

On Thu, Feb 25, 2016 at 3:32 PM, Kosyrev Serge
<_deepfire at> wrote:
> Thomas Tuegel <ttuegel at> writes:
>> Because it is not Applicative? Yes. For the same reason as Set, though, I do not
>> think it should be Foldable or Traversable. It is convenient, but unsound. Or at
>> least, less-sound. To fold or traverse Set and Map, I think the sound thing to
>> do is to use one of the provided functions to convert them to a type where
>> ordering is reflected structurally.
> What about adding unstructural fold/traversal under different names?
> That way we could have the convenience when we truly don't care about
> the directionality property, and the benefits of pure folding at the
> same time.

That's a good idea, but I don't think it really changes anything. The
chief problem with types that aren't structurally ordered is really
that there are multiple valid orders. For example, if [a] is our
canonical structurally-ordered type, there are at least two obvious
ways to write f :: Ord a => Set a -> [a]. I don't think an
unstructured version of Foldable has much benefit over simply
converting the improper type to a proper one.


More information about the Libraries mailing list