Skip to content

Fix loop #233

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

Merged
merged 9 commits into from
Oct 11, 2020
Merged

Fix loop #233

merged 9 commits into from
Oct 11, 2020

Conversation

JordanMartinez
Copy link
Contributor

Fixes #232

@@ -64,3 +65,22 @@ unlessM :: forall m. Monad m => m Boolean -> m Unit -> m Unit
unlessM mb m = do
b <- mb
unless b m

-- | `ap` provides a default implementation of `(<*>)` for any `Bind`, without
Copy link
Contributor

Choose a reason for hiding this comment

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

“for any Monad”?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Forgot to update that.

@@ -64,3 +65,22 @@ unlessM :: forall m. Monad m => m Boolean -> m Unit -> m Unit
unlessM mb m = do
b <- mb
unless b m

-- | `ap` provides a default implementation of `(<*>)` for any `Monad`, without
-- | using `(<*>)` as provided by the `Apply`-`Bind` superclass relationship.
Copy link
Contributor

Choose a reason for hiding this comment

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

Bind -> Monad here too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why? Isn't this specifically referring to Apply and Bind? Not Apply and Monad?

Copy link
Contributor

Choose a reason for hiding this comment

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

Because this function has a Monad constraint. It's saying that while you could implement ap by just writing ap = apply (since the function has a Monad constraint, and Apply is one of Monad's superclasses), we don't, because we want people to be able to write apply = ap in their Apply instances.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, thanks for clarifying.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've fixed that in latest commits.

@JordanMartinez JordanMartinez merged commit e7ce06a into purescript:master Oct 11, 2020
@JordanMartinez JordanMartinez deleted the fixLoop branch October 11, 2020 15:21
turlando pushed a commit to purescm/purescript-prelude that referenced this pull request Sep 3, 2021
* Update Apply superclass law

* Change ap constraint back to Monad

* Port `ap` back to Monad

* Reimplement `ap` using bind and pure

* Document why revert was needed

* Stop importing ap from Bind

* Update purescript-psa to v0.8.0

* Update "for any Bind" to "for any Monad"

* Update 'Apply - Bind' to 'Apply - Monad'
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.

Having ap depend on map can introduce loops
2 participants