sequences icon indicating copy to clipboard operation
sequences copied to clipboard

Please, add to/fromList conversion tests

Open Anton-Latukha opened this issue 4 years ago • 0 comments

During DList use I had a difficulty to reason about:

https://github.com/haskell/haskell-language-server/blob/2e61b7c0ba64cded22cf0fb80b089eaf328528e6/ghcide/src/Development/IDE/Core/Compile.hs#L475-L483

Because DList docs state:

fromList: ... This function is implemented with ++. Repeated uses of fromList are just as inefficient as repeated uses of ++.

So, are those 5 parallel fromLists there to do mconcat gain anything, or they are added complexity. & it is having the simple statement that DList.fromList is implemented in terms of ++. But what ++ traverses there & how many times chunks are traversed are still radically different from "just being ++" - in that source pattern conversion into DList I believe allows to save on retraverse, which ++ would do there.

As the most frequent way to construct datatypes is fromList.

And the OverloadedLists is here, together with the standardized IsList interface which it operates on.

And in the preparation for the https://github.com/fumieval/Haskell-breaking-changes#upcoming-monomorphise-datalist arrival.

It would be useful to get the tables of to/fromList conversion to see the weights of transforming the data types in the most default way.

Anton-Latukha avatar Nov 22 '21 16:11 Anton-Latukha