Several Traversable instances have an extra fmap
For example, we define
instance Traversable ZipList where
traverse f (ZipList xs) = ZipList <$> traverse f xs
If the list is very short, the extra fmap
could be bad. We can fix this by inlining the inner traverse
. However, I suspect a better approach would be to add a method to Traversable
:
mapTraverse :: Applicative f
=> (t b -> r) -> (a -> f b) -> t a -> f r
mapTraverse p f xs = p <$> traverse f xs
but I need to work through whether this is enough power to solve enough problems.
Trac metadata
Trac field | Value |
---|---|
Version | 8.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Core Libraries |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | ekmett |
Operating system | |
Architecture |