aelve / haskell-issues

An unofficial issue tracker for all things Haskell-related
18 stars 0 forks source link

<haasn> why does ‘vector’ provide mapM but not traverse #48

Open Gurkenglas opened 7 years ago

Gurkenglas commented 7 years ago

http://ircbrowse.net/browse/haskell?id=23900478&timestamp=1482366450#t1482366450

<haasn> ugh
<haasn> why does ‘vector’ provide mapM but not traverse
<Axman6> it might depend on which vector you're talking about.Data.Vector _should_ since it can hold any type, but Data.Vector.Unboxed can't because it needs to place constraints on the result type
<haasn> Axman6: I mean you could literally take the mapM_ code and change the Monad constraint to Applicative and it would still compile
<haasn> mapM*
<Axman6> yeah. file a vug =)
<Axman6> bug*
<Axman6> or, a PR
<haasn> and it would have made my life easier; but it seems somebody else has already done the work of making a traversal for Storable vectors
<Axman6> you can't implement Traversable for storable vectors
<Axman6> because Traversable doesn't allow any constraints on the result type contained in the vector
<Gurkenglas> If you're too lazy to do a PR feel free to go to https://github.com/aelve/haskell-issues/issues/new and rant about it, someone else might do it
<haasn> Axman6: traversal != Traversable
<haasn> (traversals can be monomorphic)
<Gurkenglas> Or like, I mean, I'll do it right now.
<Gurkenglas> (That is post to haskell-issues :P)
<haasn> or in this case, have an extra constraint (like with the mapM)
neongreen commented 7 years ago

https://github.com/haskell/vector/issues/69, https://github.com/haskell/vector/issues/132

Apparently it's harder than it might seem.