Skip to content

NonEmpty version of span #163

@stkb

Description

@stkb

Although a little unwieldy, the NonEmpty version of span should really have a signature like this, to preserve the non-emptyness (the current version loses it):

span :: forall a. 
  (a -> Boolean) -> 
  NonEmptyList a -> 
  Either { init :: List a, rest :: NonEmptyList a } { init :: NonEmptyList a, rest :: List a }

Or maybe it should be a new function?

Edit: Just realized it's probably just as easy to check whether init is empty and use the original list instead of rest in that case. I'll leave this here anyway

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: needs more infoThis issue needs more info before any action can be done.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions