-
Notifications
You must be signed in to change notification settings - Fork 377
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 Alternative a.k.a ApplicativePlus as distinct from implicit Monoid and Applicative together #117
Comments
I'm pleased to see this issue. Thank you for raising it, @arzig. :) When defining Rather than require a type to provide an Nothing.prototype.toBoolean = () => false;
Just.prototype.toBoolean = () => true; In order to support XOR a type must provide The hierarchy of type classes looks something this:
This isn't quite accurate, though, since AlternativeX should not require |
Does xor on its own address that case of something like
though from something like a parser. |
I don't follow, @arzig. I'm suggesting this XOR behaviour:
Option can support AND, OR, and XOR. Are you asking whether AND and OR can be derived from XOR? |
Incorrect parse of your comment. I apparently skipped the part mentioning and and or. Feel free to ignore that last bit. |
Hm, how would you specify that? Also, I don't really see what is wrong with just combining |
There are conflicting monoids for many types. However, the semantics of the monoid exposed by Alternative in Haskell or Scala is useful in many cases when you may want to provide for recovery from the "zero" case. This comes up in parsing, but also, potentially when I want to provide alternative validations against an input via one of the types that provides those semantics. |
There was a decent amount of discussion in ps-land about the laws: purescript/purescript-control#6 Also here, sanctuary-js/sanctuary#11 (comment) |
#187 seems to cover what I was initially looking for when I opened this. |
An Applicative with a Monoid instance gives rise to Alternative (Haskell) or ApplicativePlus (Scala) that is usually distinct from the Monoid formed from the semigroup of the augmented type. I was wondering if there should be an additional definition for a class like Alternative with a method name such as
choice
oror
that is specifically an Applicative with a Monoid for the higher kind itself rather than proxying to the Semigroup instance.In particular, I would love defined semantics for things like:
be defined rather than
complaining about no concat on a field.
The text was updated successfully, but these errors were encountered: