diff --git a/Funcky.Async/Funcky.Async.csproj b/Funcky.Async/Funcky.Async.csproj index 87e8ec16..f508cd7a 100644 --- a/Funcky.Async/Funcky.Async.csproj +++ b/Funcky.Async/Funcky.Async.csproj @@ -6,7 +6,7 @@ enable Extends Funcky with support for IAsyncEnumerable and Tasks. Functional Async Monad Linq - 1.1.0 + 1.2.0 true snupkg diff --git a/Funcky.Async/PublicAPI.Shipped.txt b/Funcky.Async/PublicAPI.Shipped.txt index dc858405..8e5c34b6 100644 --- a/Funcky.Async/PublicAPI.Shipped.txt +++ b/Funcky.Async/PublicAPI.Shipped.txt @@ -58,8 +58,12 @@ Funcky.Monads.OptionValueTaskAwaiter.IsCompleted.get -> bool Funcky.Monads.OptionValueTaskAwaiter.OnCompleted(System.Action! continuation) -> void Funcky.Monads.OptionValueTaskAwaiter.OptionValueTaskAwaiter() -> void Funcky.Monads.ResultAsyncExtensions +static Funcky.AsyncFunctional.RetryAsync(System.Action! action, System.Func! shouldRetry, Funcky.RetryPolicies.IRetryPolicy! retryPolicy, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask static Funcky.AsyncFunctional.RetryAsync(System.Func>>! producer, Funcky.RetryPolicies.IRetryPolicy! retryPolicy, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask> static Funcky.AsyncFunctional.RetryAsync(System.Func>>! producer, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask +static Funcky.AsyncFunctional.RetryAsync(System.Func! producer, System.Func! shouldRetry, Funcky.RetryPolicies.IRetryPolicy! retryPolicy, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask +static Funcky.AsyncFunctional.RetryAwaitAsync(System.Func! action, System.Func! shouldRetry, Funcky.RetryPolicies.IRetryPolicy! retryPolicy, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask +static Funcky.AsyncFunctional.RetryAwaitAsync(System.Func>! producer, System.Func! shouldRetry, Funcky.RetryPolicies.IRetryPolicy! retryPolicy, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask static Funcky.AsyncSequence.Concat(params System.Collections.Generic.IAsyncEnumerable![]! sources) -> System.Collections.Generic.IAsyncEnumerable! static Funcky.AsyncSequence.Concat(System.Collections.Generic.IAsyncEnumerable!>! sources) -> System.Collections.Generic.IAsyncEnumerable! static Funcky.AsyncSequence.Concat(System.Collections.Generic.IAsyncEnumerable!>! sources) -> System.Collections.Generic.IAsyncEnumerable! diff --git a/Funcky.Async/PublicAPI.Unshipped.txt b/Funcky.Async/PublicAPI.Unshipped.txt index 66bdecb4..7dc5c581 100644 --- a/Funcky.Async/PublicAPI.Unshipped.txt +++ b/Funcky.Async/PublicAPI.Unshipped.txt @@ -1,5 +1 @@ #nullable enable -static Funcky.AsyncFunctional.RetryAsync(System.Action! action, System.Func! shouldRetry, Funcky.RetryPolicies.IRetryPolicy! retryPolicy, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask -static Funcky.AsyncFunctional.RetryAsync(System.Func! producer, System.Func! shouldRetry, Funcky.RetryPolicies.IRetryPolicy! retryPolicy, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask -static Funcky.AsyncFunctional.RetryAwaitAsync(System.Func! action, System.Func! shouldRetry, Funcky.RetryPolicies.IRetryPolicy! retryPolicy, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask -static Funcky.AsyncFunctional.RetryAwaitAsync(System.Func>! producer, System.Func! shouldRetry, Funcky.RetryPolicies.IRetryPolicy! retryPolicy, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask diff --git a/Funcky/Funcky.csproj b/Funcky/Funcky.csproj index 0056eaaa..94310c52 100644 --- a/Funcky/Funcky.csproj +++ b/Funcky/Funcky.csproj @@ -7,7 +7,7 @@ Funcky Funcky is a functional C# library Functional Monad Linq - 3.1.0 + 3.2.0 true snupkg README.md diff --git a/Funcky/PublicAPI.Shipped.txt b/Funcky/PublicAPI.Shipped.txt index c929a206..70c4ba95 100644 --- a/Funcky/PublicAPI.Shipped.txt +++ b/Funcky/PublicAPI.Shipped.txt @@ -18,6 +18,8 @@ Funcky.Extensions.EnumerableExtensions Funcky.Extensions.FuncExtensions Funcky.Extensions.HttpHeadersExtensions Funcky.Extensions.HttpHeadersNonValidatedExtensions +Funcky.Extensions.ImmutableListExtensions +Funcky.Extensions.ListExtensions Funcky.Extensions.ParseExtensions Funcky.Extensions.Partitions Funcky.Extensions.Partitions @@ -89,6 +91,7 @@ Funcky.Monads.Option.AndThen(System.Func.AndThen(System.Func! selector) -> Funcky.Monads.Option Funcky.Monads.Option.CompareTo(Funcky.Monads.Option other) -> int Funcky.Monads.Option.CompareTo(object? obj) -> int +Funcky.Monads.Option.Count.get -> int Funcky.Monads.Option.Equals(Funcky.Monads.Option other) -> bool Funcky.Monads.Option.GetOrElse(System.Func! fallback) -> TItem Funcky.Monads.Option.GetOrElse(TItem fallback) -> TItem @@ -102,6 +105,7 @@ Funcky.Monads.Option.Select(System.Func! selecto Funcky.Monads.Option.SelectMany(System.Func>! selector, System.Func! resultSelector) -> Funcky.Monads.Option Funcky.Monads.Option.SelectMany(System.Func>! selector) -> Funcky.Monads.Option Funcky.Monads.Option.Switch(System.Action! none, System.Action! some) -> void +Funcky.Monads.Option.this[int index].get -> TItem Funcky.Monads.Option.ToEnumerable() -> System.Collections.Generic.IEnumerable! Funcky.Monads.Option.TryGetValue(out TItem? item) -> bool Funcky.Monads.Option.Where(System.Func! predicate) -> Funcky.Monads.Option @@ -257,6 +261,8 @@ static Funcky.Extensions.EnumerableExtensions.LastOrNone(this System.Co static Funcky.Extensions.EnumerableExtensions.LastOrNone(this System.Collections.Generic.IEnumerable! source, System.Func! predicate) -> Funcky.Monads.Option static Funcky.Extensions.EnumerableExtensions.Materialize(this System.Collections.Generic.IEnumerable! source, System.Func!, TMaterialization>! materializer) -> System.Collections.Generic.IReadOnlyCollection! static Funcky.Extensions.EnumerableExtensions.Materialize(this System.Collections.Generic.IEnumerable! source) -> System.Collections.Generic.IReadOnlyCollection! +static Funcky.Extensions.EnumerableExtensions.MaxByOrNone(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> Funcky.Monads.Option +static Funcky.Extensions.EnumerableExtensions.MaxByOrNone(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IComparer! comparer) -> Funcky.Monads.Option static Funcky.Extensions.EnumerableExtensions.MaxOrNone(this System.Collections.Generic.IEnumerable! source, System.Func>! selector) -> Funcky.Monads.Option static Funcky.Extensions.EnumerableExtensions.MaxOrNone(this System.Collections.Generic.IEnumerable! source, System.Func! selector) -> Funcky.Monads.Option static Funcky.Extensions.EnumerableExtensions.MaxOrNone(this System.Collections.Generic.IEnumerable>! source) -> Funcky.Monads.Option @@ -266,6 +272,8 @@ static Funcky.Extensions.EnumerableExtensions.Merge(this System.Collect static Funcky.Extensions.EnumerableExtensions.Merge(this System.Collections.Generic.IEnumerable! source1, System.Collections.Generic.IEnumerable! source2, Funcky.Monads.Option!> comparer = default(Funcky.Monads.Option!>)) -> System.Collections.Generic.IEnumerable! static Funcky.Extensions.EnumerableExtensions.Merge(this System.Collections.Generic.IEnumerable! source1, System.Collections.Generic.IEnumerable! source2, System.Collections.Generic.IEnumerable! source3, Funcky.Monads.Option!> comparer = default(Funcky.Monads.Option!>)) -> System.Collections.Generic.IEnumerable! static Funcky.Extensions.EnumerableExtensions.Merge(this System.Collections.Generic.IEnumerable! source1, System.Collections.Generic.IEnumerable! source2, System.Collections.Generic.IEnumerable! source3, System.Collections.Generic.IEnumerable! source4, Funcky.Monads.Option!> comparer = default(Funcky.Monads.Option!>)) -> System.Collections.Generic.IEnumerable! +static Funcky.Extensions.EnumerableExtensions.MinByOrNone(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> Funcky.Monads.Option +static Funcky.Extensions.EnumerableExtensions.MinByOrNone(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IComparer! comparer) -> Funcky.Monads.Option static Funcky.Extensions.EnumerableExtensions.MinOrNone(this System.Collections.Generic.IEnumerable! source, System.Func>! selector) -> Funcky.Monads.Option static Funcky.Extensions.EnumerableExtensions.MinOrNone(this System.Collections.Generic.IEnumerable! source, System.Func! selector) -> Funcky.Monads.Option static Funcky.Extensions.EnumerableExtensions.MinOrNone(this System.Collections.Generic.IEnumerable>! source) -> Funcky.Monads.Option @@ -338,6 +346,17 @@ static Funcky.Extensions.FuncExtensions.Uncurry(this System static Funcky.Extensions.FuncExtensions.Uncurry(this System.Func!>! function) -> System.Func! static Funcky.Extensions.HttpHeadersExtensions.GetValuesOrNone(this System.Net.Http.Headers.HttpHeaders! headers, string! name) -> Funcky.Monads.Option!> static Funcky.Extensions.HttpHeadersNonValidatedExtensions.GetValuesOrNone(this System.Net.Http.Headers.HttpHeadersNonValidated headers, string! headerName) -> Funcky.Monads.Option +static Funcky.Extensions.ImmutableListExtensions.IndexOfOrNone(this System.Collections.Immutable.IImmutableList! list, TItem item) -> Funcky.Monads.Option +static Funcky.Extensions.ImmutableListExtensions.IndexOfOrNone(this System.Collections.Immutable.IImmutableList! list, TItem item, int startIndex) -> Funcky.Monads.Option +static Funcky.Extensions.ImmutableListExtensions.IndexOfOrNone(this System.Collections.Immutable.IImmutableList! list, TItem item, int startIndex, int count) -> Funcky.Monads.Option +static Funcky.Extensions.ImmutableListExtensions.IndexOfOrNone(this System.Collections.Immutable.IImmutableList! list, TItem item, int startIndex, int count, System.Collections.Generic.IEqualityComparer? equalityComparer) -> Funcky.Monads.Option +static Funcky.Extensions.ImmutableListExtensions.IndexOfOrNone(this System.Collections.Immutable.IImmutableList! list, TItem item, System.Collections.Generic.IEqualityComparer? equalityComparer) -> Funcky.Monads.Option +static Funcky.Extensions.ImmutableListExtensions.LastIndexOfOrNone(this System.Collections.Immutable.IImmutableList! list, TItem item) -> Funcky.Monads.Option +static Funcky.Extensions.ImmutableListExtensions.LastIndexOfOrNone(this System.Collections.Immutable.IImmutableList! list, TItem item, int startIndex) -> Funcky.Monads.Option +static Funcky.Extensions.ImmutableListExtensions.LastIndexOfOrNone(this System.Collections.Immutable.IImmutableList! list, TItem item, int startIndex, int count) -> Funcky.Monads.Option +static Funcky.Extensions.ImmutableListExtensions.LastIndexOfOrNone(this System.Collections.Immutable.IImmutableList! list, TItem item, int startIndex, int count, System.Collections.Generic.IEqualityComparer? equalityComparer) -> Funcky.Monads.Option +static Funcky.Extensions.ImmutableListExtensions.LastIndexOfOrNone(this System.Collections.Immutable.IImmutableList! list, TItem item, System.Collections.Generic.IEqualityComparer? equalityComparer) -> Funcky.Monads.Option +static Funcky.Extensions.ListExtensions.IndexOfOrNone(this System.Collections.Generic.IList! list, TValue value) -> Funcky.Monads.Option static Funcky.Extensions.ParseExtensions.ParseAuthenticationHeaderValueOrNone(this string? candidate) -> Funcky.Monads.Option static Funcky.Extensions.ParseExtensions.ParseBigIntegerOrNone(this string? candidate) -> Funcky.Monads.Option static Funcky.Extensions.ParseExtensions.ParseBigIntegerOrNone(this string? candidate, System.Globalization.NumberStyles style, System.IFormatProvider? provider) -> Funcky.Monads.Option @@ -623,8 +642,10 @@ static Funcky.Functional.NoOperation(T1 ω1, T2 ω2, T3 ω3) -> void static Funcky.Functional.NoOperation(T1 ω1, T2 ω2) -> void static Funcky.Functional.NoOperation(T1 ω1) -> void static Funcky.Functional.Not(System.Func! predicate) -> System.Func! +static Funcky.Functional.Retry(System.Action! action, System.Func! shouldRetry, Funcky.RetryPolicies.IRetryPolicy! retryPolicy) -> void static Funcky.Functional.Retry(System.Func>! producer) -> TResult static Funcky.Functional.Retry(System.Func>! producer, Funcky.RetryPolicies.IRetryPolicy! retryPolicy) -> Funcky.Monads.Option +static Funcky.Functional.Retry(System.Func! producer, System.Func! shouldRetry, Funcky.RetryPolicies.IRetryPolicy! retryPolicy) -> TResult static Funcky.Functional.True() -> bool static Funcky.Functional.True(T1 ω1, T2 ω2, T3 ω3, T4 ω4) -> bool static Funcky.Functional.True(T1 ω1, T2 ω2, T3 ω3) -> bool diff --git a/Funcky/PublicAPI.Unshipped.txt b/Funcky/PublicAPI.Unshipped.txt index b678c834..7dc5c581 100644 --- a/Funcky/PublicAPI.Unshipped.txt +++ b/Funcky/PublicAPI.Unshipped.txt @@ -1,22 +1 @@ #nullable enable -Funcky.Extensions.ImmutableListExtensions -Funcky.Extensions.ListExtensions -Funcky.Monads.Option.Count.get -> int -Funcky.Monads.Option.this[int index].get -> TItem -static Funcky.Extensions.EnumerableExtensions.MaxByOrNone(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> Funcky.Monads.Option -static Funcky.Extensions.EnumerableExtensions.MaxByOrNone(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IComparer! comparer) -> Funcky.Monads.Option -static Funcky.Extensions.EnumerableExtensions.MinByOrNone(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector) -> Funcky.Monads.Option -static Funcky.Extensions.EnumerableExtensions.MinByOrNone(this System.Collections.Generic.IEnumerable! source, System.Func! keySelector, System.Collections.Generic.IComparer! comparer) -> Funcky.Monads.Option -static Funcky.Extensions.ImmutableListExtensions.IndexOfOrNone(this System.Collections.Immutable.IImmutableList! list, TItem item) -> Funcky.Monads.Option -static Funcky.Extensions.ImmutableListExtensions.IndexOfOrNone(this System.Collections.Immutable.IImmutableList! list, TItem item, int startIndex) -> Funcky.Monads.Option -static Funcky.Extensions.ImmutableListExtensions.IndexOfOrNone(this System.Collections.Immutable.IImmutableList! list, TItem item, int startIndex, int count) -> Funcky.Monads.Option -static Funcky.Extensions.ImmutableListExtensions.IndexOfOrNone(this System.Collections.Immutable.IImmutableList! list, TItem item, int startIndex, int count, System.Collections.Generic.IEqualityComparer? equalityComparer) -> Funcky.Monads.Option -static Funcky.Extensions.ImmutableListExtensions.IndexOfOrNone(this System.Collections.Immutable.IImmutableList! list, TItem item, System.Collections.Generic.IEqualityComparer? equalityComparer) -> Funcky.Monads.Option -static Funcky.Extensions.ImmutableListExtensions.LastIndexOfOrNone(this System.Collections.Immutable.IImmutableList! list, TItem item) -> Funcky.Monads.Option -static Funcky.Extensions.ImmutableListExtensions.LastIndexOfOrNone(this System.Collections.Immutable.IImmutableList! list, TItem item, int startIndex) -> Funcky.Monads.Option -static Funcky.Extensions.ImmutableListExtensions.LastIndexOfOrNone(this System.Collections.Immutable.IImmutableList! list, TItem item, int startIndex, int count) -> Funcky.Monads.Option -static Funcky.Extensions.ImmutableListExtensions.LastIndexOfOrNone(this System.Collections.Immutable.IImmutableList! list, TItem item, int startIndex, int count, System.Collections.Generic.IEqualityComparer? equalityComparer) -> Funcky.Monads.Option -static Funcky.Extensions.ImmutableListExtensions.LastIndexOfOrNone(this System.Collections.Immutable.IImmutableList! list, TItem item, System.Collections.Generic.IEqualityComparer? equalityComparer) -> Funcky.Monads.Option -static Funcky.Extensions.ListExtensions.IndexOfOrNone(this System.Collections.Generic.IList! list, TValue value) -> Funcky.Monads.Option -static Funcky.Functional.Retry(System.Action! action, System.Func! shouldRetry, Funcky.RetryPolicies.IRetryPolicy! retryPolicy) -> void -static Funcky.Functional.Retry(System.Func! producer, System.Func! shouldRetry, Funcky.RetryPolicies.IRetryPolicy! retryPolicy) -> TResult diff --git a/changelog.md b/changelog.md index c4df0d1e..357048f5 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,39 @@ All notable changes to this project will be documented in this file. Funcky adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Funcky 3.2.0 | Funcky.Async 1.2.0 +### List Pattern for Option +We've added support for C# 11's List Patterns to `Option`. +This means that you can use regular `switch` expressions / statements to match on options: + +```cs +var greeting = person switch +{ + { FirstName: var firstName, LastName: [var lastName] } => $"Hello {firstName} {lastName}", + { FirstName: var firstName } => $"Hi {firstName}", +}; + +record Person(string FirstName, Option LastName); +``` + +### Retry with Exception +We've added overloads to the `Retry` and `RetryAsync` functions that allow retrying a function +as long as an exception is thrown. + +Example from [`IoRetrier`](https://github.com/messerli-informatik-ag/io/blob/main/IO/Retrier.cs): +```cs +// Retries an action until the file is no longer in use. +Task RetryWhileFileIsInUseAsync(IRetryPolicy policy, Action action) + => RetryAsync(ActionToUnit(action), exception => exception is IOException && exception.HResult == FileInUseHResult, policy); +``` + +### New Extensions +* `EnumerableExtensions.MinByOrNone` +* `EnumerableExtensions.MaxByOrNone` +* `ImmutableListExtensions.IndexOfOrNone` +* `ImmutableListExtensions.LastIndexOfOrNone` +* `ListExtensions.IndexOfOrNone` + ## Funcky 3.1.0 | Funcky.Async 1.1.0 | Funcky.Analyzers 1.2.0 ### New APIs * ✨ `OptionExtensions.ToNullable` ✨