From 72f8ea24abe2bd02f30b5b564a78ac5980b4d853 Mon Sep 17 00:00:00 2001 From: gusty <1261319+gusty@users.noreply.github.com> Date: Wed, 7 Jan 2026 10:22:05 +0100 Subject: [PATCH 1/2] + Active Pattern for CI strings --- src/FSharpPlus/Operators.fs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/FSharpPlus/Operators.fs b/src/FSharpPlus/Operators.fs index 05d0f7dc0..ec4fe1090 100644 --- a/src/FSharpPlus/Operators.fs +++ b/src/FSharpPlus/Operators.fs @@ -7,6 +7,8 @@ open FSharpPlus.Control [] module Operators = + open FSharpPlus.Internals.Errors + // Common combinators /// Creates a new function with first two arguments flipped. @@ -1659,6 +1661,17 @@ module Operators = #endif + /// + /// An active pattern to match strings in a case-insensitive way. + /// + /// Additional Functions + let (|CiString|_|) (ciString: string) (source: string) : unit option = + let ciString = nullArgCheck (nameof ciString) ciString + let source = nullArgCheck (nameof source) source + + match source with + | s when s.Equals(ciString, StringComparison.OrdinalIgnoreCase) -> Some () + | _ -> None /// /// Safely dispose a resource (includes null-checking). From 33de4a71f00435cb2e6000891bc3b160bdf75159 Mon Sep 17 00:00:00 2001 From: gusty <1261319+gusty@users.noreply.github.com> Date: Wed, 7 Jan 2026 11:10:20 +0100 Subject: [PATCH 2/2] + Active Pattern for AggregateException --- src/FSharpPlus/Operators.fs | 21 ++++++++++++++++++--- tests/FSharpPlus.Tests/Task.fs | 5 ----- tests/FSharpPlus.Tests/ValueTask.fs | 5 ----- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/FSharpPlus/Operators.fs b/src/FSharpPlus/Operators.fs index ec4fe1090..bcda987b8 100644 --- a/src/FSharpPlus/Operators.fs +++ b/src/FSharpPlus/Operators.fs @@ -1659,7 +1659,7 @@ module Operators = /// Additional Functions let inline (|Parsed|_|) str : 'T option = tryParse str - #endif +#endif /// /// An active pattern to match strings in a case-insensitive way. @@ -1673,6 +1673,21 @@ module Operators = | s when s.Equals(ciString, StringComparison.OrdinalIgnoreCase) -> Some () | _ -> None +#if !FABLE_COMPILER + + /// + /// An active pattern to match AggregateException and extract its inner exceptions as a list. + /// + /// Additional Functions + let (|AggregateException|_|) (exn: exn) : exn list option = + let exn = nullArgCheck (nameof exn) exn + + match exn with + | :? AggregateException as aex -> aex.InnerExceptions |> Seq.toList |> Some + | _ -> None + +#endif + /// /// Safely dispose a resource (includes null-checking). /// @@ -1680,7 +1695,7 @@ module Operators = let dispose (resource: System.IDisposable) = match resource with null -> () | x -> x.Dispose () - #if !FABLE_COMPILER +#if !FABLE_COMPILER /// Additional operators for Arrows related functions which shadows some F# operators for bitwise functions. module Arrows = @@ -1701,4 +1716,4 @@ module Operators = /// Arrow Functions let inline (|||) (f: '``ArrowChoice<'T,'V>``) (g: '``ArrowChoice<'U,'V>``) : '``ArrowChoice,'V>`` = Fanin.Invoke f g - #endif +#endif diff --git a/tests/FSharpPlus.Tests/Task.fs b/tests/FSharpPlus.Tests/Task.fs index 7212ea5d3..5eb10cca3 100644 --- a/tests/FSharpPlus.Tests/Task.fs +++ b/tests/FSharpPlus.Tests/Task.fs @@ -10,11 +10,6 @@ module Task = open FSharpPlus.Tests.Helpers exception TestException of string - - let (|AggregateException|_|) (x: exn) = - match x with - | :? AggregateException as e -> e.InnerExceptions |> Seq.toList |> Some - | _ -> None module TaskTests = diff --git a/tests/FSharpPlus.Tests/ValueTask.fs b/tests/FSharpPlus.Tests/ValueTask.fs index a39e2e96a..7b20ed8e8 100644 --- a/tests/FSharpPlus.Tests/ValueTask.fs +++ b/tests/FSharpPlus.Tests/ValueTask.fs @@ -10,11 +10,6 @@ module ValueTask = open FSharpPlus.Tests.Helpers exception TestException of string - - let (|AggregateException|_|) (x: exn) = - match x with - | :? AggregateException as e -> e.InnerExceptions |> Seq.toList |> Some - | _ -> None type ValueTask<'T> with static member WhenAll (source: ValueTask<'T> seq) = source |> Seq.map (fun x -> x.AsTask ()) |> Task.WhenAll |> ValueTask<'T []>