Opened 5 years ago

Closed 5 years ago

#10060 closed bug (invalid)

The Traversable instance for Array looks unlikely to be good

Reported by: dfeuer Owned by: dfeuer
Priority: normal Milestone:
Component: Core Libraries Version: 7.11
Keywords: Cc: core-libraries-committee@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Runtime performance bug Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:



instance Ix i => Traversable (Array i) where
    traverse f arr = listArray (bounds arr) `fmap` traverse f (elems arr)

Since traverse is (inherently) not a good producer for list fusion, this looks suspicious. I think we almost certainly want to walk the array by hand instead.

Change History (2)

comment:1 Changed 5 years ago by dfeuer

Er .... actually, the situation is more complex than I thought. Specifically, it sometimes does make sense to do it somewhat like this for something like the [] applicative. Ugh. On the other hand, I don't necessarily think traversing an Array in [] is a terribly sane thing to do.

comment:2 Changed 5 years ago by dfeuer

Resolution: invalid
Status: newclosed

Yeah, this probably just isn't even possible at all. Sorry. There may be some room for improvement, but I'll need to think on it more.

Note: See TracTickets for help on using tickets.