Skip to content
David Arno edited this page Feb 17, 2020 · 1 revision

Breaking Changes introduced with v4.0.0

Details of all the changes introduced with v4.0.0 that could break your code


Why does v4 contain breaking changes?

V4 of Succinc<T> has been nearly two years in the making. It's started, stopped, scrapped, restarted, and restarted all over again as details of C# 8 were revealed and eventually released. Along the way, I've experimented with Nullable Reference Types, the new pattern matching features and read-only structs and made changes to make best use of these features. Many of these changes radically change things and so constitute breaking changes.

Changes to functional types

Maybe<T>

The struct, Maybe<T> is no more. It's an ex-type. Previously, Option<T> was a class and Maybe<T>, a struct. But Option<T> is now a read-only struct, so Maybe<T> no longer has a purpose and has been removed.

Option<T>

The Option<T> type has been changed from a class to a read-only struct. This prevents problems with null and - by using in parameters, allows it to be passed around by reference so avoids performance issues of struct copying.

The relationship between Option<T> and null has been tightened up. A null value always equates to none. Attempting to create a value via eg Option<string>.Some(null) now results in an ArgumentNullException being thrown.

In order to support C# 8's enhanced pattern matching, the supplied Deconstruct method has changed.

Either<TLeft, TRight>

This type has also changed to be a read-only struct.

Because TryLeft and TryRight return Option<TLeft> and Option<TRight>, respectively, if the value in the either is null, the try methods will now return none.

Success<T>, ValueOrError, Union<...>

All of these types have also changed to be read-only structs.

Other breaking changes

Unit.Ignore<T>(T anything)

This method is no longer required as C# 7's discards offer the same thing without needing a delegate. So this method has been removed.

TryParseEnum<T>(this string source) and TryParseEnumIgnoringCase<T>(this string source)

Both of these methods now use the struct, Enum constraint. Previously, it was just constrained to struct. This really shouldn't affect anyone as calling these with anything other than an enum type resulted in an exception being thrown.

Clone this wiki locally