Skip to content

Breaking change: Seq1 to Seq

Compare
Choose a tag to compare
@louthy louthy released this 20 Oct 15:13
· 861 commits to main since this release

This is the backstory: When language-ext was still in version 1, there was no Seq<A> collection type. There were however Seq(...) functions in the Prelude. Those functions coerced various types into being IEnumerable, and in the process protected against any of them being null.

These are they:

	Seq <A> (A? value)
	Seq <A> (IEnumerable<A> value)
	Seq <A> (A[] value)
	Seq <A> (Arr<A> value)
	Seq <A> (IList<A> value)
	Seq <A> (ICollection<A> value)
	Seq <L, R> (Either<L, R> value)
	Seq <L, R> (EitherUnsafe<L, R> value)
	Seq <A> (Try<A> value)
	Seq <A> (TryOption<A> value)
	Seq <T> (TryAsync<T> value)
	Seq <T> (TryOptionAsync<T> value)
	Seq <A> (Tuple<A> tup)
	Seq <A> (Tuple<A, A> tup)
	Seq <A> (Tuple<A, A, A> tup)
	Seq <A> (Tuple<A, A, A, A> tup)
	Seq <A> (Tuple<A, A, A, A, A> tup)
	Seq <A> (Tuple<A, A, A, A, A, A> tup)
	Seq <A> (Tuple<A, A, A, A, A, A, A> tup)
	Seq <A> (ValueTuple<A> tup)
	Seq <A> (ValueTuple<A, A> tup)
	Seq <A> (ValueTuple<A, A, A> tup)
	Seq <A> (ValueTuple<A, A, A, A> tup)
	Seq <A> (ValueTuple<A, A, A, A, A> tup)
	Seq <A> (ValueTuple<A, A, A, A, A, A> tup)
	Seq <A> (ValueTuple<A, A, A, A, A, A, A> tup)

When Seq<A> the type was added, I needed constructor functions, which are these:

    	Seq <A> ()
	Seq1 <A> (A value)
	Seq <A> (A a, A b)
	Seq <A> (A a, A b, A c, params A[] ds)

The singleton constructor needed to be called Seq1 because it was clashing with the original single-argument Seq functions from v1 of language-ext.

This has been bothering me for a long time. So, it's time to take the hit.

All of the legacy coercing functions (the first list) are now renamed to toSeq. And Seq1 has been renamed to Seq (well, Seq1 still exists, but it's marked [Obsolete].

The breaking change is that if you use any of those legacy Seq functions, you'll either need to change, this:

    Seq(blah);

Into,

    toSeq(blah);

Or,

    blah.ToSeq();

There were quite a lot of the coercion functions used in language-ext, and it took me about 10 minutes to fix it up. The good thing is that they all turn into compilation errors, no hidden behaviour changes.

Apologies for any inconvenience with this. I figure that as we've switched into v4 that this would be a good time for a clean break, and to tidy up something that I have actively seen cause confusion for devs. Seq is the most performance immutable list in the .NET sphere, so it shouldn't really be confusing to use!