-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Functor.fmap #2056
Functor.fmap #2056
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we add this it should be final. But could we just add it as syntax and not to the typeclass?
|
|
I don't have any strong opinions on this, and avoid having to do |
Hi @fosskers, can you make a mima exception, please? :) |
@SystemFw The |
Codecov Report
@@ Coverage Diff @@
## master #2056 +/- ##
==========================================
- Coverage 94.95% 94.64% -0.31%
==========================================
Files 311 318 +7
Lines 5270 5364 +94
Branches 133 119 -14
==========================================
+ Hits 5004 5077 +73
- Misses 266 287 +21
Continue to review full report at Codecov.
|
Sure, I agree that the basic problem of underlying methods taking precedence over typeclass ones is there. In any case this is making me sound way more opposed to the proposal than I actually am. My only concern is that an advanced user knows that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great addition, thank you very much @fosskers!
Lol wuh github? I didn't dismiss a review. |
It automatically dismissed reviews when you push, don't worry :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
This PR adds a
.fmap
method toFunctor
as an alias of.map
. This is in the spirit ofFoldable.combineAll
which is an alias for.fold
, as many types have a built-in.fold
with different behaviour, preventing.fold
from being injected.PROs
.fmap
is injectable, exposing lawful Functorness to implementing classes (i.e.Map
has a built-in.map
that breaks Functor laws, but its injected.fmap
would be lawful). This also benefits authors of new Functor instances.CONs
.combineAll
).flatMap
for non-Haskellers.