Skip to content

Commit e38e549

Browse files
committed
+ Active Pattern for CI strings
1 parent 7ec23cc commit e38e549

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/FSharpPlus/Operators.fs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ open FSharpPlus.Control
77
[<AutoOpenAttribute>]
88
module Operators =
99

10+
open FSharpPlus.Internals.Errors
11+
1012
// Common combinators
1113

1214
/// <summary>Creates a new function with first two arguments flipped.</summary>
@@ -1659,6 +1661,17 @@ module Operators =
16591661

16601662
#endif
16611663

1664+
/// <summary>
1665+
/// An active pattern to match strings in a case-insensitive way.
1666+
/// </summary>
1667+
/// <category index="23">Additional Functions</category>
1668+
let (|CiString|_|) (ciString: string) (source: string) : unit option =
1669+
let ciString = nullArgCheck (nameof ciString) ciString
1670+
let source = nullArgCheck (nameof source) source
1671+
1672+
match source with
1673+
| s when s.Equals(ciString, StringComparison.OrdinalIgnoreCase) -> Some ()
1674+
| _ -> None
16621675

16631676
/// <summary>
16641677
/// Safely dispose a resource (includes null-checking).

0 commit comments

Comments
 (0)