Skip to content
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

Add partial applicative typeclass functions #2545

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lmbollen
Copy link
Contributor

@lmbollen lmbollen commented Jul 14, 2023

We currently have functions like .==. that can operate on Signals. However, I find myself often writing .foo. pure bar when comparing signals to constants.

With these changes(inspired by @gergoerdi's retrocomputing lib) we can write .foo bar instead.

Still TODO:

  • Determine if there are more operators we'd like to add signal functions for.
  • Write a changelog entry (see changelog/README.md)
  • Check copyright notices are up to date in edited files

…asses.

We already have the ' .foo.' pattern for these typeclasses.
However, you often have to use '.foo . pure bar' if 'bar' is a constant.
After this change, you can use '.foo bar' instead.
@lmbollen lmbollen force-pushed the add-partial-applicative-typeclass-functions branch from cd095db to 9158361 Compare July 18, 2023 07:39
Comment on lines +1448 to +1449
(.==) :: (Eq a, Applicative f) => f a -> a -> f Bool
(.==) a b = fmap (==b) a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these new functions where only one argument is in a container don't need to be Applicative, only Functor. You hint at this in the implementations already: only fmap is needed to define these functions

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.

None yet

2 participants