-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Moved Either<,> to Unions, where it should have been in the first place. Treating this as a non-breaking change as it's an undocumented partial addition to v2.2.0. * Changed the way "any" matches are constructed for tuples. This now relies on parameters of With and Or being Either<T,Any> and the Either<,> type supporting implicit conversions from T and Any to Either<T,Any>. This removed the need to add just shy of 100 new methods to the three matcher classes used by tuple matching, plus to the interfaces and 25 or so to the tuple creation class etc. * As mentioned above, the Either<T1,T2> type now supports implicit conversions from T1 and T2. Added a bunch more tests for "nay matching" on tuples. This feature now appears to be complete.
- Loading branch information
Showing
31 changed files
with
499 additions
and
620 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,23 @@ | ||
namespace SuccincT.PatternMatchers | ||
using SuccincT.Unions; | ||
|
||
namespace SuccincT.PatternMatchers | ||
{ | ||
internal static class EitherTuple | ||
{ | ||
public static EitherTuple<T1, T2> Create<T1, T2>(T1 value1, T2 value2) => | ||
new EitherTuple<T1, T2>(value1, value2); | ||
|
||
public static EitherTuple<T1, T2> Create<T1, T2>(Any value1, T2 value2) => | ||
new EitherTuple<T1, T2>(value1, value2); | ||
|
||
public static EitherTuple<T1, T2> Create<T1, T2>(T1 value1, Any value2) => | ||
public static EitherTuple<T1, T2> Create<T1, T2>(Either<T1, Any> value1, | ||
Either<T2, Any> value2) => | ||
new EitherTuple<T1, T2>(value1, value2); | ||
|
||
public static EitherTuple<T1, T2> Create<T1, T2>(Any value1, Any value2) => | ||
new EitherTuple<T1, T2>(value1, value2); | ||
|
||
public static EitherTuple<T1, T2, T3> Create<T1, T2, T3>(T1 value1, T2 value2, T3 value3) => | ||
new EitherTuple<T1, T2, T3>(value1, value2, value3); | ||
|
||
public static EitherTuple<T1, T2, T3> Create<T1, T2, T3>(Any value1, T2 value2, T3 value3) => | ||
new EitherTuple<T1, T2, T3>(value1, value2, value3); | ||
|
||
public static EitherTuple<T1, T2, T3> Create<T1, T2, T3>(T1 value1, Any value2, T3 value3) => | ||
public static EitherTuple<T1, T2, T3> Create<T1, T2, T3>(Either<T1, Any> value1, | ||
Either<T2, Any> value2, | ||
Either<T3, Any> value3) => | ||
new EitherTuple<T1, T2, T3>(value1, value2, value3); | ||
|
||
public static EitherTuple<T1, T2, T3> Create<T1, T2, T3>(T1 value1, T2 value2, Any value3) => | ||
new EitherTuple<T1, T2, T3>(value1, value2, value3); | ||
|
||
public static EitherTuple<T1, T2, T3> Create<T1, T2, T3>(Any value1, Any value2, T3 value3) => | ||
new EitherTuple<T1, T2, T3>(value1, value2, value3); | ||
|
||
public static EitherTuple<T1, T2, T3> Create<T1, T2, T3>(Any value1, T2 value2, Any value3) => | ||
new EitherTuple<T1, T2, T3>(value1, value2, value3); | ||
|
||
public static EitherTuple<T1, T2, T3> Create<T1, T2, T3>(T1 value1, Any value2, Any value3) => | ||
new EitherTuple<T1, T2, T3>(value1, value2, value3); | ||
|
||
public static EitherTuple<T1, T2, T3> Create<T1, T2, T3>(Any value1, Any value2, Any value3) => | ||
new EitherTuple<T1, T2, T3>(value1, value2, value3); | ||
public static EitherTuple<T1, T2, T3, T4> Create<T1, T2, T3, T4>(Either<T1, Any> value1, | ||
Either<T2, Any> value2, | ||
Either<T3, Any> value3, | ||
Either<T4, Any> value4) => | ||
new EitherTuple<T1, T2, T3, T4>(value1, value2, value3, value4); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using SuccincT.Unions; | ||
|
||
namespace SuccincT.PatternMatchers | ||
{ | ||
internal struct EitherTuple<T1, T2, T3, T4> | ||
{ | ||
private readonly Either<T1, Any> _value1; | ||
private readonly Either<T2, Any> _value2; | ||
private readonly Either<T3, Any> _value3; | ||
private readonly Either<T4, Any> _value4; | ||
|
||
internal EitherTuple(Either<T1, Any> value1, | ||
Either<T2, Any> value2, | ||
Either<T3, Any> value3, | ||
Either<T4, Any> value4) | ||
{ | ||
_value1 = value1; | ||
_value2 = value2; | ||
_value3 = value3; | ||
_value4 = value4; | ||
} | ||
|
||
public bool MatchesTuple(Tuple<T1, T2, T3, T4> tuple) => | ||
(!_value1.IsLeft || EqualityComparer<T1>.Default.Equals(_value1.Left, tuple.Item1)) && | ||
(!_value2.IsLeft || EqualityComparer<T2>.Default.Equals(_value2.Left, tuple.Item2)) && | ||
(!_value3.IsLeft || EqualityComparer<T3>.Default.Equals(_value3.Left, tuple.Item3)) && | ||
(!_value4.IsLeft || EqualityComparer<T4>.Default.Equals(_value4.Left, tuple.Item4)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 5 additions & 1 deletion
6
SuccincT/PatternMatchers/IActionWithHandler{TM,T1,T2,T3,T4}.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 4 additions & 8 deletions
12
SuccincT/PatternMatchers/IActionWithHandler{TM,T1,T2,T3}.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.