Skip to content

Added Discard instance #21

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
wants to merge 1 commit into from

Conversation

Risto-Stevcev
Copy link

No description provided.

@paf31
Copy link
Contributor

paf31 commented May 31, 2017

I don't think errors should be discardable.

@Risto-Stevcev
Copy link
Author

liftEff and launchAff get used often enough, and those values are worth ignoring a lot of the time. For liftEff, if it has a type signature like Either Error Unit, I don't see an issue with discarding that

@paf31
Copy link
Contributor

paf31 commented May 31, 2017

I think encouraging users to discard errors like this would be a bad thing.

@Risto-Stevcev
Copy link
Author

They would still be able to discard it using _ <-. Isn't the Discard class and instances (or lack thereof) just avoiding the extra boilerplate? What would it be stopping people from doing that they can't already do?

@paf31
Copy link
Contributor

paf31 commented May 31, 2017

The point of Discard is to force users to acknowledge that they are discarding something which is non-trivial. Error is non-trivial, so users should be forced to acknowledge it. In fact, it's sort of the perfect example of what Discard is for 😄

@Risto-Stevcev
Copy link
Author

The point of Discard is to force users to acknowledge that they are discarding something which is non-trivial

I guess I just don't understand what this is accomplishing. Doesn't this only benefit people who are new to purescript and don't understand that every line in a do block returns a value?

Everyone who's familiar with do notation knows that if they write foo bar in a do block, that it's equivalent to _ <- foo bar, and not having a Discard instance doesn't prevent someone from writing _ <- instead of whatever <-

@paf31
Copy link
Contributor

paf31 commented May 31, 2017

Doesn't this only benefit people who are new to purescript and don't understand that every line in a do block returns a value?

No, I've had bugs recently which were caused by my forgetting to use a value returned in a do block.

@paf31
Copy link
Contributor

paf31 commented May 31, 2017

Also, if you think Discard is not accomplishing anything, then we should discuss it on the compiler issue tracker. It seems like Error is an arbitrary choice in that case.

@garyb
Copy link
Member

garyb commented May 31, 2017

No, I've had bugs recently which were caused by my forgetting to use a value returned in a do block.

Likewise, that's why it was proposed in the first place - GHC warns about it too for similar reasoning.

👎 from to this from me I'm afraid!

@Risto-Stevcev
Copy link
Author

Huh, that's interesting. I've never ran into an issue with that, but you guys have way more experience coding in purescript than me. Ok I guess if it's a 👎 I'll go ahead and close this PR

@garyb
Copy link
Member

garyb commented May 31, 2017

There's an example of the kind of place it can occur in purescript/purescript#1803 (comment) - due to a use of <$> rather than a =<< in that case. It's not super common, but I have done it (or things like it) several times, it's tricky to track down why an effect is not occurring :)

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.

3 participants