5

I'm looking up sets and converting sets to lists in Haskell, and I see this:

Convert the set to a list of elements. Subject to list fusion.

(https://hackage.haskell.org/package/containers-0.5.10.2/docs/Data-Set.html)

I see this in many of the functions handling conversion of sets and lists. When do I need to worry about what this does, and what do I need to think about in such cases? Do I only need to worry about it if I am dealing with streams, as the proposed duplicate question suggests?

fhyve
  • 323
  • 2
  • 13
  • In short: transformations such that the overhead of intermediate datastructures is reduced (by rewriting the functions that these datastructures are no longer necessary for instance). – Willem Van Onsem Nov 06 '17 at 18:47
  • It's basically the use of [rewrite rules](https://hackage.haskell.org/package/base-4.10.0.0/docs/src/GHC.Base.html#augment) that, as Willem said, removes intermediate datastructures/results. See https://downloads.haskell.org/~ghc/8.0-latest/docs/html/users_guide/glasgow_exts.html#list-fusion. – Zeta Nov 06 '17 at 18:53
  • So is this only relevant when using streams/infinite lists? – fhyve Nov 06 '17 at 19:03
  • 1
    I would also consider this a slightly non-duplicate question. To elaborate my question: when would I need to care about what list fusion does when using these set-to-list functions (as opposed to knowing the details about what list fusion is and how it does it)? – fhyve Nov 06 '17 at 19:05
  • This refers to an internal implementation detail. You would not be using streams directly. The comment in the documentation just tells you that it can perform the fusion optimization, due to its implementation. – David Young Nov 06 '17 at 20:43
  • 2
    Also, what do you mean by "worry about"? The results won't change, so if you're not concerned about performance, you never really need to worry about it. Also, in this context, "stream" doesn't really refer to an infinite list. – David Young Nov 06 '17 at 20:49
  • 2
    "The results won't change, so if you're not concerned about performance, you never really need to worry about it." That answers my question in the negative. – fhyve Nov 07 '17 at 07:03

0 Answers0