Skip to content

Law-abiding Apply NonEmptyList that agrees with Apply List #221

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

Closed

Conversation

UnrelatedString
Copy link

Description of the change

Rewrote the faulty

instance applyNonEmptyList :: Apply NonEmptyList where
  apply (NonEmptyList (f :| fs)) (NonEmptyList (a :| as)) =
    NonEmptyList (f a :| (fs <*> a : Nil) <> ((f : fs) <*> as))

to

instance applyNonEmptyList :: Apply NonEmptyList where
  apply (NonEmptyList (f :| fs)) (NonEmptyList (a :| as)) =
    NonEmptyList (f a :| map f as <> apply fs (a : as))

and likewise for the lazy equivalent. The majority of the commits were adding massively-overkill test machinery because I couldn't actually think of an example of how this failed to obey the Apply law without randomly generating one, but this can safely be removed (and I will gladly do so, or even make a new PR from a branch without those commits, if asked) because the single new test

log "apply should agree with Apply List"
  assert $ l (Tuple <$> nel 1 [2, 3, 4] <*> nel 'a' ['b', 'c', 'd']) == (Tuple <$> l [1, 2, 3, 4] <*> l ['a', 'b', 'c', 'd'])

should suffice.

...I also accidentally included the contents of my earlier PR #220,


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)

UnrelatedString and others added 30 commits February 27, 2025 15:02
~~made the CI woke~~ making CI workflow run on renamed main branch after splitting off the unfoldable1 feature branch so I can PR said feature branch to both my own main branch and the official master branch without having to undo the rename in ci.yml for the official PR
Fixed my bad guess for PR name
Make `Data.List.NonEmpty.toUnfoldable` and `Data.List.Lazy.NonEmpty.toUnfoldable` work with `Unfoldable1`
…ast this is *getting* there and a vastly better idea than the other stuff I tried. afraid of actually putting a spago.yaml in the top level since that could mess with publishing though... copying the dependencies in seems bad for maintainability but for something this low level with so few dependencies I guess it should be Fine
…ing's deprecated. LMAO. aaaaand of course having this as its own recursive dependency kinda messes things up after all :P
…t exist on bower and I still get four modules not found ;_;
…rce latest thing messed up the existing committed resolve and now I just have to save it all manually don't I
@UnrelatedString
Copy link
Author

...also realized there are personal tweaks to the CI in there that weren't supposed to be in ANY PR. oops

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant