Skip to content

Consider strictness of unzip/unzipWith #162

Open

Description

@treeowl

My personal intuition suggests that most instances should be "strict in the leaves, lazy in the spine" like the [] instance. However, most of them seem to be lazy all over the place.

NB: Data.Sequence.Seq actually needs its unzip to be lazy in the leaves in order to be lazy in the spine. If it tried to be strict in the leaves but lazy in the spine, it would end up being strict in part of the spine, which would break the abstraction barrier. sigh.

Activity

  1. treeowl commented on Aug 22, 2021

    @treeowl
    Author

    Thinking about this a bit more, I wonder if it would actually make sense to offer several more unzipping methods, to get precisely the behavior you want.

    1. Strict in the leaf-pair separation; strict in the spine.
    2. Strict in the leaf-pair separation; lazy in the spine if possible.
    3. Lazy in the leaf-pair separation; strict in the spine.
    4. Lazy in the leaf-pair separation; lazy in the spine if possible.

    I would expect all of them to be head-strict (unzip _|_ = _|_), though that might be a tad confusing for a functor like Identity.

    We can offer sensible defaults of all of these except (as far as I can tell) lazy-spine/strict-separation for Traversable types. I think that one type probably just requires too much human judgement to say what it means.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions