purescript-lists icon indicating copy to clipboard operation
purescript-lists copied to clipboard

Infix operator (:||) for NonEmptyList cons'

Open milesfrain opened this issue 4 years ago • 4 comments

Description of the change

Motivation for this change is to give users a more ergonomic alternative to: https://github.com/purescript/purescript-lists/blob/6d8e30eeb9714bc422b6fb75ad1b0f43bef59703/src/Data/List.purs#L619-L620

We can currently do a little better with NonEmpty's :| operator:

(NonEmptyList (1 :| 3 : Nil)) : (NonEmptyList (2 :| Nil)) : (NonEmptyList (4 :| Nil)) : (NonEmptyList (3 :| (3 : Nil))) : Nil

But it's even nicer with this change, which introduces the :|| operator for cons'.

(1 :|| 3 : Nil) : (2 :|| Nil) : (4 :|| Nil) : (3 :|| 3 : Nil) : Nil

I'd ideally like to reuse the :| operator, but that leads to complications since we then can't use that operator for pattern matching anymore (it's equivalent to NonEmptyList (NonEmpty x xs). The new version is no longer a simple data constructor of 2 arguments. We'd likely need to enable Pattern Synonyms for that to work.


Checklist:

  • [ ] Added the change to the changelog's "Unreleased" section with a reference to this PR (e.g. "- Made a change (#0000)")
  • [ ] Linked any existing issues or proposals that this pull request should close
  • [ ] Updated or added relevant documentation
  • [ ] Added a test for the contribution (if applicable)

milesfrain avatar Jan 13 '21 00:01 milesfrain

Adding this would be non-breaking so I'd suggest leaving this until after v0.14.0.

hdgarrood avatar Jan 14 '21 13:01 hdgarrood

@hdgarrood Why wait to merge this if it builds and is otherwise acceptable?

JordanMartinez avatar Jan 15 '21 13:01 JordanMartinez

Because we should be focusing on getting v0.14.0 out - it's been in the pipeline for far too long already.

hdgarrood avatar Jan 15 '21 15:01 hdgarrood

What is the current status of this proposal? It is planned to be merged?

Masynchin avatar Nov 08 '22 17:11 Masynchin