Skip to content

Commit 2085239

Browse files
Clean up the docs
1 parent 4146782 commit 2085239

File tree

11 files changed

+49
-49
lines changed

11 files changed

+49
-49
lines changed

CHANGELOG.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
Whats's new in version 3.1.0:
66

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 for .NET 6+
7+
- .NET Standard 2.0 support was added back
108
- `BinarryFormatter` support was removed from `MatchException`
9+
- Matchmaker is now built with .NET 9
10+
- Trimming is now enabled only for .NET 6 or later
1111
- Docs now use a new theme
1212
- Docs for older versions were removed
1313

@@ -17,7 +17,7 @@ Whats's new in version 3.0.1:
1717

1818
- No changes to the library's code or API
1919
- Matchmaker is now built with .NET 6 and uses C# 10 (but still targets .NET Standard 2.1)
20-
- Improved the NuGet package (added a symbol package, a readme, and Source Link)
20+
- The NuGet package was improved (a symbol package, a readme, and Source Link were added)
2121
- The library is now trimmable
2222
- GitHub Actions are now used for CI instead of AppVeyor
2323

Matchmaker/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ an object, and use it multiple times on different input values.
6262

6363
- The default case is a pattern, just like any other. It's called `Any` and is always matched successfully.
6464

65-
- Like in `switch` the patterns are tried out sequentially. This means that the `Any` pattern should always come last.
65+
- Like in `switch`, the patterns are tried out sequentially. This means that the `Any` pattern should always come last.
6666

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

7171
Here's what the equivalent switch expression looks like in C# 8 or later:
7272

@@ -232,8 +232,8 @@ articles provide everything you need to know to use this library.
232232
If you need extensive information, go to the [API reference](https://matchmaker.tolik.io/api/index.html).
233233

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

238238
## Is This Library Still Maintained?
239239

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ an object, and use it multiple times on different input values.
7070

7171
- The default case is a pattern, just like any other. It's called `Any` and is always matched successfully.
7272

73-
- Like in `switch` the patterns are tried out sequentially. This means that the `Any` pattern should always come last.
73+
- Like in `switch`, the patterns are tried out sequentially. This means that the `Any` pattern should always come last.
7474

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

7979
Here's what the equivalent switch expression looks like in C# 8 or later:
8080

@@ -240,8 +240,8 @@ articles provide everything you need to know to use this library.
240240
If you need extensive information, go to the [API reference](https://matchmaker.tolik.io/api/index.html).
241241

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

246246
## Is This Library Still Maintained?
247247

docs/articles/async.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pattern is matched successfully (sync actions are turned into async actions).
4444

4545
Async match expressions can be executed using the `ExecuteAsync`, `ExecuteNonStrictAsync` and
4646
`ExecuteWithFallthroughAsync` methods. The `ToFunction` method and its variations are also available.
47-
`ExecuteWithFallthroughAsync` returns an `IAsyncEnumerable` which enable lazy async execution of match expressions.
47+
`ExecuteWithFallthroughAsync` returns an `IAsyncEnumerable` which enables lazy async execution of match expressions.
4848

4949
The `Matchmaker.Linq` namespace contains the `EnumerateAsync` extension method for `IAsyncEnumerable<T>` which
5050
enumerates it and ignores the result. You can use it if you just want to execute the match statement with fall-through.

docs/articles/expressions.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ A match expression can be created using the `Create` methods of the static class
1313
### Adding Cases
1414

1515
The `Match` classes include `Case` methods which are used to add a pattern and a function which is executed if the match
16-
is successful. Match expressions are immutable `Case` methods return new match expressions; they do not affect the
16+
is successful. Match expressions are immutable `Case` methods return new match expressions; they do not affect the
1717
ones on which they are called.
1818

19-
`Case` methods are generic they also contain information about the pattern's transformation type. Match expressions
19+
`Case` methods are generic they also contain information about the pattern's transformation type. Match expressions
2020
can contain patterns of arbitrary transformation types without knowing about these types.
2121

2222
### Executing Match Expressions
@@ -31,7 +31,7 @@ which executes the match expression in the non-strict mode. It returns `MatchRes
3131
not be present.
3232

3333
In the `Match<TInput>` class, the `ExecuteOn` method doesn't return anything, and also throws a `MatchException` if the
34-
match wasn't successful. This class also contains the `ExecuteNonStrict` method it returns a boolean value which
34+
match wasn't successful. This class also contains the `ExecuteNonStrict` method it returns a boolean value which
3535
indicates whether the match was successful and doesn't throw an exception if it wasn't.
3636

3737
The `ToFunction` method and its variations are also available. They return a function which, when called, will execute
@@ -54,8 +54,8 @@ the expression will stop at this pattern and not go any further.
5454

5555
`Match.Create` is also overloaded to take the default fall-through behavior.
5656

57-
Matching with fall-through is lazy i.e. it returns an `IEnumerable` and is only executed when this enumerable is
58-
enumerated. Because matching will fall-through is lazy, it doesn't have any modes of execution the user must decide
57+
Matching with fall-through is lazy, i.e., it returns an `IEnumerable` and is only executed when this enumerable is
58+
enumerated. Because matching will fall-through is lazy, it doesn't have any modes of execution the user must decide
5959
whether to throw an exception or not if there were no successful matches.
6060

6161
In the `Match<TInput, TOutput>` class, the `ExecuteWithFallthrough` method returns an `IEnumerable<TOutput>` which can
@@ -121,15 +121,15 @@ void DoStuff(int i) =>
121121
```
122122

123123
The problem here is that if we call `DoStuff` 10,000 times, we will initialize the match expression 10,000 times as
124-
well, even though it's actually the same expression. Having just 4 cases may not seem like much, but the lag does
125-
accumulate if we execute it thousands of times.
124+
well, even though it's actually the same expression. Having just 4 cases may not seem like much, but the lag and
125+
allocations do accumulate if we execute it thousands of times.
126126

127127
We can save the expression in a field and then call the `ExecuteOn` method on this field. But this makes the code much
128128
less readable because the case definitions are in a different place from the actual execution point.
129129

130130
### The Solution
131131

132-
There is a way to create static match expressions expressions which will be initialized only once.
132+
There is a way to create static match expressions expressions which will be initialized only once.
133133

134134
The `Match` class contains the `CreateStatic` methods which allow the creation of static match expressions. Take a look
135135
at the modified example:
@@ -150,7 +150,7 @@ only once, and its initialization code is in the same place as its execution poi
150150

151151
The parameter of the build action has the type `MatchBuilder<TInput, TOutput` or `MatchBuilder<TInput>`, depending on
152152
which type of match expressions you are building. This type has the same methods for adding cases as the `Match` classes
153-
and is mutable the methods return the same builder instance.
153+
and is mutable the methods return the same builder instance.
154154

155155
`MatchBuilder` also has the `Fallthrough` method which specifies the default fall-through behavior. But this method
156156
specifies fall-through behavior only for cases that are defined after it. For example:

docs/articles/migration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ This article describes how to migrate to version 2.0.0 from
66
If you need to migrate from older versions, first migrate to version 1.2.0. You can do that just by reading the
77
changelog, because previous versions contained much fewer changes and it's much simpler to migrate.
88

9-
In order to migrate from version 2.0.0 to version 2.1.0 action is required only if you implemented the
9+
In order to migrate from version 2.0.0 to version 2.1.0, action is required only if you implemented the
1010
`IPattern<TInput, TMatchResult>` interface (which wasn't recommended). The less generic `IPattern<TInput>` interface was
1111
removed, so you should remove its `Match` method. That's it.
1212

1313
No changes are required to migrate from version 2.1.0 to 3.1.0. Version 3.0.0 removed support for .NET Standard 2.0, but
14-
version 3.1.0 added it back, effectively undoing the only breaking change of 3.0.0.
14+
version 3.1.0 added it back, effectively undoing its only breaking change.
1515

1616
## General
1717

docs/articles/patterns.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ The `Match` method actually does two things:
1919
- Matches the input value with the pattern and returns a successful result if the match is successful.
2020
- Transforms the input value. The returned result contains the transformed value if it's successful.
2121

22-
Since options are not supported natively in C#, a custom type [`MatchResult<T>`](results.md) is used.
22+
Since options are not supported natively in C#, a custom type [`MatchResult<T>`](results.md) is used.
2323

2424
The definition of patterns is similar to F#'s active patterns.
2525

26-
Descriptions for patterns are not terribly important, but can be useful for debugging. As such, they are optional if
26+
Descriptions for patterns are not terribly important, but can be useful for debugging. As such, they are optional if
2727
you don't want a pattern to have a description, it should be empty. A pattern's description should never be `null`.
2828

2929
## Null Values
@@ -59,7 +59,7 @@ All methods for getting predefined patterns are overloaded to take a custom desc
5959
The `Matchmaker.Linq` namespace provides several extension methods for patterns:
6060

6161
- `Select` maps a pattern's result value if it's successful.
62-
- `Pipe` creates a pattern pipeline the result of the first pattern is the input of the second pattern.
62+
- `Pipe` creates a pattern pipeline the result of the first pattern is the input of the second pattern.
6363
- `Cast` casts a pattern's result to a specified type. It's the same as piping a pattern to the `Type` pattern. If the
6464
input is `null`, then the match will fail only if the destination type is a non-nullable value type.
6565
- `Bind` flat-maps a pattern's result. If a pattern's result is successful, it calls the specified function and passes
@@ -70,7 +70,7 @@ result is the final result.
7070
the input if successful.
7171
- `Compose` is the same as the three methods above, but the composition operator is passed to it as well.
7272
- `Cached` returns a pattern which matches the same as the specified pattern but caches its results in a `null`-safe
73-
hash table. Every input will be matched only once if it's matched again, the result will be taken from the cache. The
73+
hash table. Every input will be matched only once if it's matched again, the result will be taken from the cache. The
7474
caching process is not thread-safe.
7575

7676
All extension methods for patterns are overloaded to take a custom description.
@@ -82,10 +82,10 @@ a combination of the Reader and Maybe monads.
8282

8383
## Immutability
8484

85-
Every predefined pattern as well as patterns returned by the `CreatePattern` and extension methods are immutable.
86-
Calling an extension method on a pattern returns a new pattern the old one is unchanged.
85+
All predefined patterns, as well as patterns returned by `CreatePattern` and extension methods, are immutable. Calling
86+
an extension method on a pattern returns a new pattern the old one is unchanged.
8787

88-
An exception is the pattern returned by the `Cached` method, which is not immutable it holds a mutable cache. But if a
88+
An exception is the pattern returned by the `Cached` method, which is not immutable it holds a mutable cache. But if a
8989
pattern is referentially transparent (its `Match` method always returns the same result for the same input and doesn't
9090
have any side effects), then the caching pattern based on it can be thought of as immutable as well, because it doesn't
9191
matter how many times the base pattern's `Match` method is called.
@@ -109,7 +109,7 @@ There are also overloads which take a description.
109109

110110
If you want something more complex than a single function, you can create a class which extends the
111111
`Matchmaker.Patterns.Pattern<TInput, TMatchResult>` class. This is a base class for patterns, and it implements the
112-
`Description` property which you don't have to use if you don't want by default the description is empty, which means
112+
`Description` property which you don't have to use if you don't want by default the description is empty, which means
113113
that the pattern doesn't have a description.
114114

115115
You can also implement the `IPattern<TInput, TMatchResult>` interface directly. There is no reason to do that instead of

docs/articles/results.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ may want just pattern matching and nothing else.
1212
- Users may use a different library/framework for functional features. There are a lot of those for C#.
1313

1414
So, starting with version 2, instead of using the `OptionUnsafe<T>` type from language-ext, this library includes a
15-
`MatchResult<T>` type. This type is much like optional types from other libraries in that it may contain a value, or may
16-
not, except for a couple differences:
15+
`MatchResult<T>` type. This type works much like optional types from other libraries in that it may contain a value, or
16+
may not, except for a couple differences:
1717

1818
- `MatchResult<T>` is not a general-purpose optional type and shouldn't be used as such.
1919
- `MatchResult<T>` can contain `null` values and this is important to remember. This type is not used to avoid

docs/articles/unions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public int Sum(ConsList list)
7373

7474
As you can see, we have to throw an exception in the `switch` version, because C# can't know that `ConsCell` and `Empty`
7575
are the only possible subclasses of `ConsList`. And for that reason, if we forget to define one of the cases in `switch`
76-
or in a match, we'll get an exception. In F# a warning is issued when the match is incomplete, but C# doesn't have the
76+
or in a match, we'll get an exception. In F#, a warning is issued when the match is incomplete, but C# doesn't have the
7777
notion of complete or incomplete matches. Of course, this match will fail if the provided list is `null`, but this can
7878
be handled using the `Null` pattern.
7979

0 commit comments

Comments
 (0)