polyadic / funcky

Funcky is a Functional Library for C#
https://polyadic.github.io/funcky
Apache License 2.0
19 stars 3 forks source link

Consider change of return type of Materialize to IReadOnlyList<T> #733

Closed Mafii closed 1 year ago

Mafii commented 1 year ago

This may be controversial, but it has an advantage:

Currently, list patterns can't be used with IReadOnlyCollection, which is a bummer. With IReadOnlyList that would work.

bash commented 1 year ago

First of all: This would be a breaking change, so if we wanted to do this, we'd have to wait for Funcky 4.0.

The point of materialize is to ... well ... materialize, so for instance for a Set<T> you will get the set back as-is even though a set is not a list. Materialize focuses on the lowest common denominator which is IReadOnlyCollection<T>[^1].

I suggest we implement your proposal as a separate method instead (something like MaterializeAsList) if we have enough use cases for it.

[^1]: That's of course only partially true because ICollection<T> doesn't inherit from IReadOnlyCollection<T> 🙃