Skip to content

Commit c69f531

Browse files
Update the readme and the changelog
1 parent ae6c002 commit c69f531

File tree

3 files changed

+61
-69
lines changed

3 files changed

+61
-69
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## v3.1.0
4+
5+
Whats's new in version 3.1.0:
6+
7+
- .NET Standard 2.0 support was added back, but without nullable reference types
8+
- Matchmaker is now built with .NET 9
9+
- Trimming is now enabled only in .NET 6+
10+
311
## v3.0.1
412

513
Whats's new in version 3.0.1:

Matchmaker/README.md

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Version 1.x can be found there. This package contains version 2+.
1010

1111
This is what the simplest match expression looks like:
1212

13-
```
13+
```c#
1414
using static Matchmaker.Patterns.Pattern;
1515

1616
// ...
@@ -29,7 +29,7 @@ string result =
2929

3030
This is what an equivalent `switch` statement looks like (pre-C# 8):
3131

32-
```
32+
```c#
3333
string result;
3434
int i = 5;
3535

@@ -65,13 +65,13 @@ in an object, and use it multiple times on different input values.
6565
- Like in `switch` the patterns are tried out sequentially. This means that the `Any` pattern should always
6666
come last.
6767

68-
C# 8 included a new way to write `switch` expressions which yield a value, and C# 9 extended it quite a bit. This
69-
drastically reduced the need for external libraries like this one for pattern matching. However, this library lets the
70-
user define arbitrary patterns, which makes this library more powerful than the `switch` expressions.
68+
C# 8 included a new way to write `switch` expressions which yield a value, and further versions extended it quite a bit.
69+
This drastically reduced the need for external libraries like this one for pattern matching. However, this library lets
70+
the user define arbitrary patterns, which makes this library more powerful than the `switch` expressions.
7171

72-
Here's what the equivalent switch expression looks like in C# 8:
72+
Here's what the equivalent switch expression looks like in C# 8 or later:
7373

74-
```
74+
```c#
7575
int i = 5;
7676

7777
string result = i switch
@@ -85,14 +85,14 @@ string result = i switch
8585
```
8686

8787
OK, this is much shorter and cleaner than the previous two examples. But this library shines when the patterns are
88-
more complex. While C# allowes various kinds of patterns, this library allows anything you can think about.
88+
more complex. While C# allows various kinds of patterns, this library allows anything you can think of.
8989

9090
## Another Example
9191

9292
Let's define a simple list, implemented as [cons cells](https://en.wikipedia.org/wiki/Cons). This list is not
9393
generic for simplicity.
9494

95-
```
95+
```c#
9696
public abstract class ConsList
9797
{
9898
private protected ConsList()
@@ -127,7 +127,7 @@ public sealed class Empty : ConsList
127127
Now let's look what pattern matching on the list would look like. Let's create
128128
a function which finds the sum of all items of the list.
129129

130-
```
130+
```c#
131131
public int Sum(ConsList list) =>
132132
Match.Create<ConsList, int>()
133133
.Case<ConsCell>(cell => cell.Head + Sum(cell.Tail))
@@ -139,7 +139,7 @@ public int Sum(ConsList list) =>
139139

140140
Here is the equivalent function implemented using the `switch` statement (pre-C# 8):
141141

142-
```
142+
```c#
143143
public int Sum(ConsList list)
144144
{
145145
switch (list)
@@ -156,13 +156,13 @@ public int Sum(ConsList list)
156156

157157
As you can see, we have to throw an exception in the `switch` version, because C# can't know that `ConsCell`
158158
and `Empty` are the only possible subclasses of `ConsList`. And for that reason, if we forget to define one
159-
of the cases in `switch` or in a match, we'll get an exception. In F# a warning is issued when the match is
159+
of the cases in `switch` or in a match, we'll get an exception. In F#, a warning is issued when the match is
160160
incomplete, but C# doesn't have the notion of complete or incomplete matches.
161161

162162
With C# 8 there's a better way to do this, but we still have to explicitly throw an exception
163163
in the default case (which we know won't happen):
164164

165-
```
165+
```c#
166166
public int Sum(ConsList list) =>
167167
list switch
168168
{
@@ -176,11 +176,11 @@ public int Sum(ConsList list) =>
176176
## Matching with Fall-through
177177

178178
C, C++ and, Java support fall-through in `switch` statements. So does this library, although it works differently here.
179-
You can read more [here](https://matchmaker.tolik.io/v3.0.0/articles/expressions.html#matching-with-fall-through).
179+
You can read more [here](https://matchmaker.tolik.io/articles/expressions.html#matching-with-fall-through).
180180

181181
Here's an implementation of the famous fizz-buzz program which uses matching with fall-through:
182182

183-
```
183+
```c#
184184
using System.Linq;
185185

186186
using Matchmaker;
@@ -202,7 +202,8 @@ var result = Enumerable.Range(0, 15)
202202
.Select(items => items.Aggregate(String.Concat))
203203
.ToList();
204204

205-
// The result is ("FizzBuzz", "1", "2", "Fizz", "4", "Buzz", "Fizz", "7", "8", "Fizz", "Buzz", "11", "Fizz", "13", "14", "FizzBuzz");
205+
// The result is:
206+
// "FizzBuzz", "1", "2", "Fizz", "4", "Buzz", "Fizz", "7", "8", "Fizz", "Buzz", "11", "Fizz", "13", "14", "FizzBuzz"
206207
```
207208

208209
## Static Match Expressions
@@ -211,7 +212,7 @@ One pain point of match expressions is that whenever a method which contains a m
211212
expression is initialized from scratch every time. This can be solved with static match expressions. Take a look at
212213
the revised simple example:
213214

214-
```
215+
```c#
215216
string result = Match.CreateStatic<int, string>(match => match
216217
.Case(EqualTo(1), _ => "one")
217218
.Case(EqualTo(2), _ => "two")
@@ -222,29 +223,25 @@ string result = Match.CreateStatic<int, string>(match => match
222223
```
223224

224225
Now this match expression will be initialized only once even if its containing method is executed multiple times.
225-
You can read more [here](https://matchmaker.tolik.io/v3.0.0/articles/expressions.html#static-match-expressions).
226+
You can read more [here](https://matchmaker.tolik.io/articles/expressions.html#static-match-expressions).
226227

227228
## More Info
228229

229-
If you want to learn how to use this library, you should read the [documentation](https://matchmaker.tolik.io/v3.0.0).
230+
If you want to learn how to use this library, you should read the [documentation](https://matchmaker.tolik.io).
230231
The articles provide everything you need to know to use this library.
231232

232-
If you need extensive information, go to the [API reference](https://matchmaker.tolik.io/v3.0.0/api/index.html).
233+
If you need extensive information, go to the [API reference](https://matchmaker.tolik.io/api/index.html).
233234

234235
If you need even more info about this library, you can go through the
235-
[tests](https://github.com/TolikPylypchuk/Matchmaker/tree/v3.0.0/Matchmaker.Tests). They are property-based and as such
236+
[tests](https://github.com/TolikPylypchuk/Matchmaker/Matchmaker.Tests). They are property-based and as such
236237
they describe every aspect of the classes and their members.
237238

238239
## Is This Library Still Maintained?
239240

240-
I'm not planning on writing new versions beyond 3.0 (or maybe 3.1 if some stuff needs fixing). To be fair, I thought
241+
I'm not planning on writing new versions beyond 3.1 (or maybe 3.2 if some stuff needs fixing). To be fair, I thought
241242
the same thing after releasing version 1.1 and yet here we are. This time I do believe that this library has enough
242-
features (probably more than enough). Maybe one day I'll revisit this decision, but for now (January 2022) this is it;
243+
features (probably more than enough). Maybe one day I'll revisit this decision, but for now (June 2025) this is it;
243244
this is as good as it gets.
244245

245246
That said, if you report a bug or request a new feature, I'll definitely look into it. I'm not giving up on this
246247
library any time soon.
247-
248-
## License
249-
250-
[MIT License](https://github.com/TolikPylypchuk/Matchmaker/blob/master/LICENSE)

README.md

Lines changed: 29 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,15 @@ Version 1.x can be found there. This repository contains version 2+.
1010

1111
## Installation
1212

13-
If your platform supports .NET Standard 2.1, you can install the latest version:
14-
15-
```
16-
dotnet add package Matchmaker --version 3.0.1
17-
```
18-
19-
If it doesn't, then stick to versions 2.x:
20-
2113
```
22-
dotnet add package Matchmaker --version 2.1.0
14+
dotnet add package Matchmaker
2315
```
2416

2517
## A Simple Example
2618

2719
This is what the simplest match expression looks like:
2820

29-
```
21+
```c#
3022
using static Matchmaker.Patterns.Pattern;
3123

3224
// ...
@@ -45,7 +37,7 @@ string result =
4537

4638
This is what an equivalent `switch` statement looks like (pre-C# 8):
4739

48-
```
40+
```c#
4941
string result;
5042
int i = 5;
5143

@@ -81,13 +73,13 @@ in an object, and use it multiple times on different input values.
8173
- Like in `switch` the patterns are tried out sequentially. This means that the `Any` pattern should always
8274
come last.
8375

84-
C# 8 included a new way to write `switch` expressions which yield a value, and C# 9 extended it quite a bit. This
85-
drastically reduced the need for external libraries like this one for pattern matching. However, this library lets the
86-
user define arbitrary patterns, which makes this library more powerful than the `switch` expressions.
76+
C# 8 included a new way to write `switch` expressions which yield a value, and further versions extended it quite a bit.
77+
This drastically reduced the need for external libraries like this one for pattern matching. However, this library lets
78+
the user define arbitrary patterns, which makes this library more powerful than the `switch` expressions.
8779

88-
Here's what the equivalent switch expression looks like in C# 8:
80+
Here's what the equivalent switch expression looks like in C# 8 or later:
8981

90-
```
82+
```c#
9183
int i = 5;
9284

9385
string result = i switch
@@ -101,14 +93,14 @@ string result = i switch
10193
```
10294

10395
OK, this is much shorter and cleaner than the previous two examples. But this library shines when the patterns are
104-
more complex. While C# allowes various kinds of patterns, this library allows anything you can think about.
96+
more complex. While C# allows various kinds of patterns, this library allows anything you can think of.
10597

10698
## Another Example
10799

108100
Let's define a simple list, implemented as [cons cells](https://en.wikipedia.org/wiki/Cons). This list is not
109101
generic for simplicity.
110102

111-
```
103+
```c#
112104
public abstract class ConsList
113105
{
114106
private protected ConsList()
@@ -143,7 +135,7 @@ public sealed class Empty : ConsList
143135
Now let's look what pattern matching on the list would look like. Let's create
144136
a function which finds the sum of all items of the list.
145137

146-
```
138+
```c#
147139
public int Sum(ConsList list) =>
148140
Match.Create<ConsList, int>()
149141
.Case<ConsCell>(cell => cell.Head + Sum(cell.Tail))
@@ -155,7 +147,7 @@ public int Sum(ConsList list) =>
155147

156148
Here is the equivalent function implemented using the `switch` statement (pre-C# 8):
157149

158-
```
150+
```c#
159151
public int Sum(ConsList list)
160152
{
161153
switch (list)
@@ -172,13 +164,13 @@ public int Sum(ConsList list)
172164

173165
As you can see, we have to throw an exception in the `switch` version, because C# can't know that `ConsCell`
174166
and `Empty` are the only possible subclasses of `ConsList`. And for that reason, if we forget to define one
175-
of the cases in `switch` or in a match, we'll get an exception. In F# a warning is issued when the match is
167+
of the cases in `switch` or in a match, we'll get an exception. In F#, a warning is issued when the match is
176168
incomplete, but C# doesn't have the notion of complete or incomplete matches.
177169

178170
With C# 8 there's a better way to do this, but we still have to explicitly throw an exception
179171
in the default case (which we know won't happen):
180172

181-
```
173+
```c#
182174
public int Sum(ConsList list) =>
183175
list switch
184176
{
@@ -192,11 +184,11 @@ public int Sum(ConsList list) =>
192184
## Matching with Fall-through
193185

194186
C, C++ and, Java support fall-through in `switch` statements. So does this library, although it works differently here.
195-
You can read more [here](https://matchmaker.tolik.io/v3.0.1/articles/expressions.html#matching-with-fall-through).
187+
You can read more [here](https://matchmaker.tolik.io/articles/expressions.html#matching-with-fall-through).
196188

197189
Here's an implementation of the famous fizz-buzz program which uses matching with fall-through:
198190

199-
```
191+
```c#
200192
using System.Linq;
201193

202194
using Matchmaker;
@@ -218,7 +210,8 @@ var result = Enumerable.Range(0, 15)
218210
.Select(items => items.Aggregate(String.Concat))
219211
.ToList();
220212

221-
// The result is ("FizzBuzz", "1", "2", "Fizz", "4", "Buzz", "Fizz", "7", "8", "Fizz", "Buzz", "11", "Fizz", "13", "14", "FizzBuzz");
213+
// The result is:
214+
// "FizzBuzz", "1", "2", "Fizz", "4", "Buzz", "Fizz", "7", "8", "Fizz", "Buzz", "11", "Fizz", "13", "14", "FizzBuzz"
222215
```
223216

224217
## Static Match Expressions
@@ -227,7 +220,7 @@ One pain point of match expressions is that whenever a method which contains a m
227220
expression is initialized from scratch every time. This can be solved with static match expressions. Take a look at
228221
the revised simple example:
229222

230-
```
223+
```c#
231224
string result = Match.CreateStatic<int, string>(match => match
232225
.Case(EqualTo(1), _ => "one")
233226
.Case(EqualTo(2), _ => "two")
@@ -238,37 +231,31 @@ string result = Match.CreateStatic<int, string>(match => match
238231
```
239232

240233
Now this match expression will be initialized only once even if its containing method is executed multiple times.
241-
You can read more [here](https://matchmaker.tolik.io/v3.0.1/articles/expressions.html#static-match-expressions).
234+
You can read more [here](https://matchmaker.tolik.io/articles/expressions.html#static-match-expressions).
242235

243236
## More Info
244237

245-
If you want to learn how to use this library, you should read the [documentation](https://matchmaker.tolik.io/v3.0.1).
238+
If you want to learn how to use this library, you should read the [documentation](https://matchmaker.tolik.io).
246239
The articles provide everything you need to know to use this library.
247240

248-
If you need extensive information, go to the [API reference](https://matchmaker.tolik.io/v3.0.1/api/index.html).
241+
If you need extensive information, go to the [API reference](https://matchmaker.tolik.io/api/index.html).
249242

250243
If you need even more info about this library, you can go through the
251-
[tests](https://github.com/TolikPylypchuk/Matchmaker/tree/v3.0.1/Matchmaker.Tests). They are property-based and as such
244+
[tests](https://github.com/TolikPylypchuk/Matchmaker/Matchmaker.Tests). They are property-based and as such
252245
they describe every aspect of the classes and their members.
253246

254-
The documentation can be found here:
255-
256-
- Version 3.0.1: https://matchmaker.tolik.io/v3.0.1
257-
- Version 3.0.0: https://matchmaker.tolik.io/v3.0.0
258-
- Version 2.1.0: https://matchmaker.tolik.io/v2.1.0
259-
- Version 2.0.0: https://matchmaker.tolik.io/v2.0.0
260-
- Older versions: https://github.com/TolikPylypchuk/PatternMatching
261-
262247
## Is This Library Still Maintained?
263248

264-
I'm not planning on writing new versions beyond 3.0 (or maybe 3.1 if some stuff needs fixing). To be fair, I thought
249+
I'm not planning on writing new versions beyond 3.1 (or maybe 3.2 if some stuff needs fixing). To be fair, I thought
265250
the same thing after releasing version 1.1 and yet here we are. This time I do believe that this library has enough
266-
features (probably more than enough). Maybe one day I'll revisit this decision, but for now (January 2022) this is it;
251+
features (probably more than enough). Maybe one day I'll revisit this decision, but for now (June 2025) this is it;
267252
this is as good as it gets.
268253

269254
That said, if you report a bug or request a new feature, I'll definitely look into it. I'm not giving up on this
270255
library any time soon.
271256

272-
## License
257+
## Icon
273258

274-
[MIT License](https://github.com/TolikPylypchuk/Matchmaker/blob/master/LICENSE)
259+
Icon made by [Roundicons](https://www.flaticon.com/authors/roundicons) from
260+
[www.flaticon.com](https://www.flaticon.com) and is licensed by
261+
[CC 3.0 BY](http://creativecommons.org/licenses/by/3.0/).

0 commit comments

Comments
 (0)