-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Infix operator (:||) for NonEmptyList cons' #190
base: master
Are you sure you want to change the base?
Conversation
|
||
snoc :: forall a. NonEmptyList a -> a -> NonEmptyList a | ||
snoc (NonEmptyList (x :| xs)) y = NonEmptyList (x :| L.snoc xs y) | ||
snoc (NonEmptyList (x :| xs)) y = x :|| L.snoc xs y |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we could get pattern matching to work, and reuse :|
, we could rewrite this (and friends) as:
snoc (x :| xs) y = x :| L.snoc xs y
e64a80f
to
f0a589c
Compare
Adding this would be non-breaking so I'd suggest leaving this until after v0.14.0. |
@hdgarrood Why wait to merge this if it builds and is otherwise acceptable? |
Because we should be focusing on getting v0.14.0 out - it's been in the pipeline for far too long already. |
What is the current status of this proposal? It is planned to be merged? |
Description of the change
Motivation for this change is to give users a more ergonomic alternative to:
purescript-lists/src/Data/List.purs
Lines 619 to 620 in 6d8e30e
We can currently do a little better with NonEmpty's
:|
operator:But it's even nicer with this change, which introduces the
:||
operator forcons'
.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 toNonEmptyList (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: