No iterator package?

Hi,

I have a use case that fits very nicely with the iterator pattern - specifically chaining and cycling iterators. I found https://package.elm-lang.org/packages/fabiommendes/elm-iter/latest/, but couldn’t quite see how to use it. In this package, the iterator state is exposed, which means the type depends on what function is called. This means it’s impossible to declare a struct containing an iterator without knowing if it is the result of Iter.fromList or Iter.concat or something else.

I made a library myself where every iterator function simply returns Iter a. I might publish it if there’s any interest, but I am no Elm expert yet, so can’t make any performance claims. The code certainly looks clean, mostly due to Elm itself :slightly_smiling_face:

I guess my question is if there exists such a package that I have not found.

1 Like

Do you mean something like this? :slight_smile:

https://package.elm-lang.org/packages/the-sett/lazy-list/latest/Seq

2 Likes

Yeah, now that I actually read the docs and not just the README, this fits perfectly :sunglasses: Thanks!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.