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

Error typeclass #72

Closed
ktonga opened this issue Jun 26, 2018 · 8 comments
Closed

Error typeclass #72

ktonga opened this issue Jun 26, 2018 · 8 comments
Labels
question Further information is requested

Comments

@ktonga
Copy link
Contributor

ktonga commented Jun 26, 2018

In the same vein as Haskell's Exception

In addition to be just a marker TC it could have functions such as defaultError which could be useful to define a meaningful MonadPlus for IO

@ktonga ktonga added the question Further information is requested label Jun 26, 2018
@fommil
Copy link
Contributor

fommil commented Jun 26, 2018

@emilypi ^^^

@jdegoes
Copy link
Member

jdegoes commented Jun 26, 2018

@ktonga Why not mzero(Monoid zero) for MonadPlus?

@ktonga
Copy link
Contributor Author

ktonga commented Jun 26, 2018

That makes it harder to distinguish the empty IO (from other failed) in plus to hold the identity laws. It's not impossible, the implementation will differ from the one in Plus and we have to add Monoid and Equal constrains to E. If the default error is a singleton it is simpler and clearer.

@ktonga
Copy link
Contributor Author

ktonga commented Jun 26, 2018

Another useful method could be isRetryable. I'm not saying we should mark E with it everywhere, just add the constraint when it makes sense and we can provide more functionality. For instance there could be two flavors of maybeRetry one with the constraint and another accepting an E => Boolean

@fommil
Copy link
Contributor

fommil commented Jun 26, 2018

@jdegoes check my comments about that. We can do it, but it will mean an object allocation, and requiring Equal[E] (as well as Monoid[E]), and we have to be careful about breaking coherence in the implicit priorities for the case where there is no Equal or Monoid.

https://github.com/scalaz/ioeffect/blob/master/ioeffect/src/main/scala/scalaz/ioeffect/IOInstances.scala#L48-L55

@fommil
Copy link
Contributor

fommil commented Jun 26, 2018

(I'll code it up so we can see exactyl what I mean...)

@fommil
Copy link
Contributor

fommil commented Jun 26, 2018

scalaz/ioeffect#61

@ktonga
Copy link
Contributor Author

ktonga commented Jun 26, 2018

Monoidal E it is

@ktonga ktonga closed this as completed Jun 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants