more code

This commit is contained in:
Francesco Mecca 2024-12-13 11:04:50 +01:00
parent 67ff51521b
commit a3cf2d87a6
3 changed files with 28 additions and 16 deletions

View file

@ -1,5 +1,6 @@
namespace Pentole namespace Pentole
/// The initially opened module.
[<AutoOpen>] [<AutoOpen>]
module Pervasives = module Pervasives =
@ -7,3 +8,10 @@ module Pervasives =
/// The identity function. /// The identity function.
/// </summary> /// </summary>
let identity = id let identity = id
/// An active pattern that matches strings starting with a specified prefix.
let (|Prefix|_|) (p: string) (s: string) =
if s.StartsWith p then
s.Substring p.Length |> Some
else
None

View file

@ -1,6 +1,8 @@
module Pentole.String namespace Pentole
let split (separator: string) (target: string) : string list = module String =
let split (separator: string) (target: string) : string list =
if System.String.IsNullOrEmpty separator then if System.String.IsNullOrEmpty separator then
[target] [target]
else else

View file

@ -2,6 +2,8 @@ namespace Pentole
open NUnit.Framework open NUnit.Framework
type TestAttribute = NUnit.Framework.TestAttribute
module Assert = module Assert =
let inline okEquals<'ok, 'err> (expected: 'ok) (got: Result<'ok, 'err>) = let inline okEquals<'ok, 'err> (expected: 'ok) (got: Result<'ok, 'err>) =
match got with match got with