reasonml-community / belt

MIT License
49 stars 1 forks source link

Composable iterators #22

Open strega-nil opened 6 years ago

strega-nil commented 6 years ago

related to #20

strega-nil commented 6 years ago

What I'd like to be able to do:

let arr =
  iter(arr)
  |> Iter.enumerate
  |> Iter.map(((n, x)) => x + n)
  |> Array.from_iter;
kavorite commented 6 years ago

https://github.com/rizo/iter/ seems to have a lot of what you need; I'm leery of interoperability with existing implementations and standard API but enough love and it should be workable

it would certainly be nice to see something closer to the core of the ecosystem, but it seems polished, and as I work more to leverage OPAM I'm finding this 'fragmentation' of community-developed tooling and libraries to be pretty pervasive, but the products to be extremely useful; the general feel is that the standard isn't moving fast enough or breaking enough things, so to compensate, people have adopted innovative features from other languages and invented new solutions, which I see as a reaffirmation of the power of the ML core and the fact that software developers are just humans taking care of their needs, with the werewithal to put some thought into maybe taking care of ours

truly inspiring to see a suite of tools as powerful as OCaml for abstraction over not-so-sexy things in not-so-sexy ways that actually has a pulse

rauschma commented 6 years ago

Ideally, this would work with both JS code and be truly functional at the same time. Not sure that’s possible, though – it’s a tall order.

ckknight commented 6 years ago

It'd be nice if there were some way to convert a JS object that has a well-implemented [Symbol.iterator] method and convert that into a well-typed value that is easy-to-use from ReasonML.