DEV Community


Discussion on: Functional handling of Collections in Java using Streams

iquardt profile image
Iven Marquardt • Edited

I just want to clarify what the term Stream means in FP. We already have stream-like behavior with lazy linked Lists. Lists differ from Streams in two properties though:

  • they are a sum type (tagged union) with Cons/Nil as cases, whereas Stream doesn't need a Nil case
  • the tail of the List isn't wrapped in a monad so pulling out new elements cannot depend on an effect (this again is possible with the next step in Streams)

Streams are more expressive than Lists and you can apply fusion on it (avoiding intermediate structures) but it also loses some features like sharing, for instance (you can share a list).

jannikwempe profile image
Jannik Wempe Author

Hi Iven,
thanks for the clarification, awesome!

Of course this article is more focused on the provided API than the underlying concept of streams. Therefore your comment is a nice addition.