nevalang / neva

🌊 Flow-based programming language with static types and implicit parallelism. Compiles to native code and Go
https://nevalang.org
MIT License
85 stars 7 forks source link

`Index` flow has a generic signature that doesn't make sense. #680

Closed Catya3 closed 2 weeks ago

Catya3 commented 2 weeks ago

The Index flow has a generic signature that doesn't make sense.

// Index returns the element at the given index in the ordered collection.
// If the index is out of bounds, it returns an error.
// The index is zero-based.
#extern(index)
pub flow Index<T list<any> | string>(data T, idx int) (res T, err error)

We would expect res to have the element type but instead it's a list<any>.

We may wish to separate this into strings.Index and lists.Index until/if we can more precisely capture this.

I have lists.Index under the name lists.At in https://github.com/nevalang/neva/pull/679