I recently wrote an internal lib that for many functions it takes a list or a stream and returns a stream. It's the responsibility of the user to run the stream. For my use case I used a guard which only permitted a list or a struct (Stream) as I couldn't figure out a better system. For my tests I just used a list with Stream.take to create a stream.
On that note I'd like it if there was a Stream.t() akin to String.t() for type definitions. On Tuesday, July 23, 2024 at 3:17:34 PM UTC-6 José Valim wrote: > Is there any benefit in calling Stream.new(enum)? All streams are enums > and not all streams are Stream, so nowhere you should be checking for > Stream in particular. > > On Tue, Jul 23, 2024 at 23:00 Robert Dober <robert...@gmail.com> wrote: > >> Hi there >> >> for eternity (there was no life before Elixir, right?) I was creating >> streams from enumerables with >> >> - Stream.map(enum, &(&1)) >> >> trying to find something better I found, somethoing worse, I believe >> >> - Stream.concat(enum, []) >> >> and, please forgive me, I wont do it again... >> >> - %Stream{enum: enum} >> >> >> I would gladly provide a PR for implementing Stream.new/1 if so desired. >> >> KR >> Robert >> >> -- >> You received this message because you are subscribed to the Google Groups >> "elixir-lang-core" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to elixir-lang-co...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/elixir-lang-core/7b9cab1c-37fe-4cce-90f7-cd81c3835b65n%40googlegroups.com >> >> <https://groups.google.com/d/msgid/elixir-lang-core/7b9cab1c-37fe-4cce-90f7-cd81c3835b65n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/1f013b9b-f39e-4532-b171-866d159ff3a3n%40googlegroups.com.