This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "nuget: Nito.AsyncEx, 5.1.2" | |
open System.Threading | |
open System.Threading.Tasks | |
open Nito.AsyncEx | |
let work x y = | |
async { | |
do! Async.Sleep 1 | |
return 1 + 2 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let work x y = async { | |
return x + y // doesn't matter _what_ the work is | |
} | |
let sendWorkers x y = async { | |
let! workerBee1 = work (x) (y) |> Async.StartChild | |
let! workerBee2 = work (x) (y+1) |> Async.StartChild | |
let! workerBee3 = work (x) (y+2) |> Async.StartChild | |
// collect results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open System.Text.RegularExpressions | |
let alternativeCharacters = dict [ ' ', ' ' ] | |
let bypassCharactersJoined = "" | |
let escape s = | |
String.map (fun character -> match alternativeCharacters.TryGetValue(character) with (true, c) -> c | (false, _) -> character) s | |
let tryMatch pattern s = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "nuget: FSharp.SystemTextJson, 0.17.4" | |
module Database = | |
open System.Text.Json.Serialization | |
open System.Text.Json | |
let options = | |
let o = JsonSerializerOptions() | |
o.Converters.Add(JsonFSharpConverter()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "nuget: Newtonsoft.Json" | |
open Newtonsoft.Json | |
type Person = { First: string; Last: string } | |
type Employee = Employee of person: Person | Manager of manager: Person * employees: Employee list | |
let chet = Employee { First = "Chet"; Last = "Husk"} | |
let tim = Manager ({ First = "Tim"; Last = "Heuer"}, [chet]) | |
let data = Map.ofList [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<OutputType>Exe</OutputType> | |
<TargetFramework>net7.0</TargetFramework> | |
<!-- Super critical - ensure your generation target runs _before_ the IncrementalClean target, which happens before `CoreCompile` --> | |
<IncrementalCleanDependsOn>GenerateFile;$(IncrementalCleanDependsOn)</IncrementalCleanDependsOn> | |
</PropertyGroup> | |
<Target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "nuget: Expecto" | |
open Expecto | |
let dependentTest testName condition testCase = | |
test testName { | |
if condition then | |
testCase () | |
else | |
skiptestf "Expecto: condition failed" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "nuget: System.CommandLine, 2.0.0-beta3.22106.2" | |
open System.CommandLine | |
open System.CommandLine.Builder | |
open System.CommandLine.Parsing | |
open System.CommandLine.Invocation | |
open System.Threading.Tasks | |
open System | |
let args = fsi.CommandLineArgs[1..] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "nuget: RestoreSources=https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-libraries/nuget/v3/index.json" | |
#r "nuget: System.CommandLine, 2.0.0-beta3.22076.2" | |
open System.CommandLine | |
open System.CommandLine.Parsing | |
open System | |
[<return:Struct>] | |
let inline (|EqualsIC|_|) l r = if String.Equals(l, r, StringComparison.OrdinalIgnoreCase) then ValueSome () else ValueNone | |
[<return:Struct>] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "nuget: System.CommandLine, 2.0.0-beta2.21623.1" | |
#r "nuget: RestoreSources=https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-libraries/nuget/v3/index.json" | |
open System.CommandLine | |
open System.IO | |
open System.Threading.Tasks | |
let tagCommand = Command("tag-extract", "Get content with the given tag") | |
let inputfileArg = Argument<FileInfo>("input-file", "the file to extract content from") | |
tagCommand.AddArgument inputfileArg |