Use coercions to implement fmapDefault and foldMapDefault
We should be able to use
fmapDefault :: Traversable t => (a -> b) -> t a -> t b
fmapDefault = (getId .) #. traverse .# (Id .)
foldMapDefault :: (Traversable t, Monoid m) => (a -> m) -> t a -> m
foldMapDefault = (getConst .) #. traverse .# (Const .)
where .#
and #.
are coercion operators found in Data.Profunctor.Unsafe
. This should help when the function passed in doesn't inline.
Trac metadata
Trac field | Value |
---|---|
Version | 8.0.1 |
Type | Task |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Core Libraries |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | ekmett |
Operating system | |
Architecture |