Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v5 #249

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
Draft

v5 #249

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"paket": {
"version": "8.0.0",
"version": "8.0.3",
"commands": [
"paket"
]
Expand Down
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"ghcr.io/devcontainers-contrib/features/starship:1": {},
// https://github.com/devcontainers/features/blob/main/src/dotnet/README.md
"ghcr.io/devcontainers/features/dotnet:2": {
"version": "7.0",
"additionalVersions": "6.0"
"version": "8.0",
"additionalVersions": "7.0,6.0"
},
"ghcr.io/devcontainers/features/node:1": {
"version": "18"
Expand Down
23 changes: 18 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
name: Build master

on: [push, pull_request]
on:
# Runs only on pushes to the default branch or pull requests to the default branch
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:

jobs:

Expand All @@ -12,7 +20,7 @@ jobs:
# Builds for Debug and Release configurations
configuration: [Debug, Release]
# Builds for Ubuntu, Windows, and macOS
os: [ubuntu-latest, windows-latest, macOS-latest]
os: [ubuntu-latest, windows-latest, macOS-latest, macos-14]
runs-on: ${{ matrix.os }}

steps:
Expand All @@ -22,6 +30,8 @@ jobs:
with:
global-json-file: global.json
dotnet-version: |
8.x
7.x
6.x

- name: Build via Bash
Expand All @@ -44,7 +54,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
os: [ubuntu-latest, windows-latest, macOS-latest, macos-14]
node-version: ['18', '20', 'latest' ]
runs-on: ${{ matrix.os }}

Expand All @@ -61,6 +71,8 @@ jobs:
with:
global-json-file: global.json
dotnet-version: |
8.x
7.x
6.x

- name: Build via Bash
Expand All @@ -82,7 +94,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
os: [ubuntu-latest, windows-latest, macOS-latest, macos-14]
python-version: ['3.10', '3.11', '3.12']
runs-on: ${{ matrix.os }}

Expand All @@ -99,8 +111,9 @@ jobs:
with:
global-json-file: global.json
dotnet-version: |
8.x
7.x
6.x

- name: Build via Bash
if: runner.os != 'Windows'
run: |
Expand Down
997 changes: 500 additions & 497 deletions .paket/Paket.Restore.targets

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project>
<PropertyGroup>
<DisableCheckingDuplicateNuGetItems>true</DisableCheckingDuplicateNuGetItems>
<NoWarn>$(NoWarn);FS2003</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
</PropertyGroup>
<PropertyGroup>
<DisableCheckingDuplicateNuGetItems>true</DisableCheckingDuplicateNuGetItems>
<NoWarn>$(NoWarn);FS2003; NU1903; NU1904</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
</PropertyGroup>
</Project>
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The library provides utility functions like `map`, `bind`, `apply`, `traverse`,

It was inspired by [Chessie](https://github.com/fsprojects/Chessie) and Cvdm.ErrorHandling (the latter has now been merged into FsToolkit.ErrorHandling).

FsToolkit.ErrorHandling targets .NET Standard 2.0 and .NET Framework 4.6.1 and supports Fable.
FsToolkit.ErrorHandling targets .NET Standard 2.0, .NET Standard2.1 and supports Fable.

## Documentation

Expand Down Expand Up @@ -47,6 +47,7 @@ This repository has a devcontainer setup for VSCode. For more infomation see:
* [.NET Core SDK](https://www.microsoft.com/net/download/)
* [v6.x](https://dotnet.microsoft.com/en-us/download/dotnet/6.0)
* [v7.x](https://dotnet.microsoft.com/en-us/download/dotnet/7.0)
* [v8.x](https://dotnet.microsoft.com/en-us/download/dotnet/8.0)

#### Optional

Expand Down
4 changes: 4 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 5.0.0-alpha.1
- [refactor!: Seq.sequenceResultM returns Array instead of seq](https://github.com/demystifyfp/FsToolkit.ErrorHandling/pull/255) [@bartelink](https://github.com/bartelink)
- [feat(Seq): sequenceResultA](https://github.com/demystifyfp/FsToolkit.ErrorHandling/pull/255) [@bartelink](https://github.com/bartelink)

### 4.15.1 - January 15, 2024
- [Doc updates](https://github.com/demystifyfp/FsToolkit.ErrorHandling/pull/247) Credits @1eyewonder

Expand Down
55 changes: 0 additions & 55 deletions benchmarks/ApplicativeTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,6 @@ type Result_BindvsAndCEBenchmarks() =
}
|> ignore

[<Benchmark>]
member this.All_Success_And() =
result {
let! r1 = successSlowSync this.delay
and! r2 = successSlowSync this.delay
and! r3 = successSlowSync this.delay

return
r1
+ r2
+ r3
}
|> ignore

[<Benchmark>]
member this.Fail_First_Bind() =
Expand All @@ -69,20 +56,6 @@ type Result_BindvsAndCEBenchmarks() =
}
|> ignore

[<Benchmark>]
member this.Fail_First_And() =
result {
let! r1 = errorSlowSync this.delay
and! r2 = successSlowSync this.delay
and! r3 = successSlowSync this.delay

return
r1
+ r2
+ r3
}
|> ignore

[<Benchmark>]
member this.Fail_Mid_Bind() =
result {
Expand All @@ -97,20 +70,6 @@ type Result_BindvsAndCEBenchmarks() =
}
|> ignore

[<Benchmark>]
member this.Fail_Mid_And() =
result {
let! r1 = successSlowSync this.delay
and! r2 = errorSlowSync this.delay
and! r3 = successSlowSync this.delay

return
r1
+ r2
+ r3
}
|> ignore

[<Benchmark>]
member this.Fail_Last_Bind() =
result {
Expand All @@ -124,17 +83,3 @@ type Result_BindvsAndCEBenchmarks() =
+ r3
}
|> ignore

[<Benchmark>]
member this.Fail_Last_And() =
result {
let! r1 = successSlowSync this.delay
and! r2 = successSlowSync this.delay
and! r3 = errorSlowSync this.delay

return
r1
+ r2
+ r3
}
|> ignore
79 changes: 67 additions & 12 deletions build/build.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,30 @@ open System.IO
open Fake.BuildServer
open FsToolkit.Build

let environVarAsBoolOrDefault varName defaultValue =
let truthyConsts = [
"1"
"Y"
"YES"
"T"
"TRUE"
]

try
let envvar = (Environment.environVar varName).ToUpper()

truthyConsts
|> List.exists ((=) envvar)
with _ ->
defaultValue

let project = "FsToolkit.ErrorHandling"

let summary =
"FsToolkit.ErrorHandling is a utility library to work with the Result type in F#, and allows you to do clear, simple and powerful error handling."

let isCI = lazy (environVarAsBoolOrDefault "CI" false)

let isRelease (targets: Target list) =
targets
|> Seq.map (fun t -> t.Name)
Expand Down Expand Up @@ -93,6 +112,18 @@ let failOnBadExitAndPrint (p: ProcessResult) =

failwithf "failed with exitcode %d" p.ExitCode

// github actions are terrible and will cancel runner operations if using too much CPU
// https://github.com/actions/runner-images/discussions/7188#discussioncomment-6672934
let maxCpuCount = lazy (if isCI.Value then Some(Some 2) else None)

/// MaxCpu not used on unix https://github.com/fsprojects/FAKE/blob/82e38df01e4b31e5daa3623abff57e6462430395/src/app/Fake.DotNet.MSBuild/MSBuild.fs#L858-L861
let maxCpuMsBuild =
lazy
(match maxCpuCount.Value with
| None -> ""
| Some None -> "/m"
| Some(Some x) -> $"/m:%d{x}")

module dotnet =
let watch cmdParam program args =
DotNet.exec cmdParam (sprintf "watch %s" program) args
Expand Down Expand Up @@ -143,11 +174,24 @@ let clean _ =
|> Seq.iter Shell.rm


let build ctx =
let setParams (defaults: DotNet.BuildOptions) = {
module BuildParameters =
let common (defaults: MSBuild.CliArguments) = {
defaults with
DisableInternalBinLog = true
}

let build ctx =

let args = [ maxCpuMsBuild.Value ]

let setParams (c: DotNet.BuildOptions) = {
c with
NoRestore = true
Configuration = (configuration ctx.Context.AllExecutingTargets)
MSBuildParams = BuildParameters.common c.MSBuildParams
Common =
c.Common
|> DotNet.Options.withAdditionalArgs args
}

DotNet.build setParams solutionFile
Expand All @@ -159,14 +203,22 @@ let restore _ =
ToolType = ToolType.CreateLocalTool()
})

DotNet.restore id solutionFile
let setParams (c: DotNet.RestoreOptions) = {
c with
MSBuildParams = BuildParameters.common c.MSBuildParams
}

DotNet.restore setParams solutionFile

let npmRestore _ = Npm.install id


let dotnetTest ctx =

let args = [ "--no-build" ]
let args = [
"--no-build"
maxCpuMsBuild.Value
]

DotNet.test
(fun c ->
Expand All @@ -177,6 +229,7 @@ let dotnetTest ctx =
Common =
c.Common
|> DotNet.Options.withAdditionalArgs args
MSBuildParams = BuildParameters.common c.MSBuildParams
})
solutionFile

Expand Down Expand Up @@ -293,14 +346,16 @@ let dotnetPack ctx =
// ./bin from the solution root matching the "PublishNuget" target WorkingDir
OutputPath = Some distDir
Configuration = configuration ctx.Context.AllExecutingTargets
MSBuildParams = {
MSBuild.CliArguments.Create() with
// "/p" (property) arguments to MSBuild.exe
Properties = [
("Version", release.NugetVersion)
("PackageReleaseNotes", releaseNotes)
]
}
MSBuildParams =
{
MSBuild.CliArguments.Create() with
// "/p" (property) arguments to MSBuild.exe
Properties = [
("Version", release.NugetVersion)
("PackageReleaseNotes", releaseNotes)
]
}
|> BuildParameters.common
})
)

Expand Down
22 changes: 11 additions & 11 deletions build/build.fsproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<Compile Include="DotEnv.fs" />
<Compile Include="build.fs" />
</ItemGroup>
<Import Project="..\.paket\Paket.Restore.targets" />
</Project>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<Compile Include="DotEnv.fs" />
<Compile Include="build.fs" />
</ItemGroup>
<Import Project="..\.paket\Paket.Restore.targets" />
</Project>
3 changes: 3 additions & 0 deletions gitbook/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
* [sequenceResultM](list/sequenceResultM.md)
* [traverseResultA](list/traverseResultA.md)
* [sequenceResultA](list/sequenceResultA.md)
* Seqs
* [sequenceResultM](seq/sequenceResultM.md)
* [sequenceResultA](seq/sequenceResultA.md)
* Transforms
* [ofChoice](result/ofChoice.md)

Expand Down
2 changes: 1 addition & 1 deletion gitbook/list/sequenceResultA.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ let checkIfAllPrime (numbers : int list) =
numbers
|> List.map isPrime // Result<bool, string> list
|> List.sequenceResultA // Result<bool list, string list>
|> Result.map (List.forall id) // shortened version of '|> Result.map (fun boolList -> boolList |> List.map (fun x -> x = true))'
|> Result.map (List.forall id) // shortened version of '|> Result.map (fun boolList -> boolList |> List.forall (fun x -> x = true))

let a = [1; 2; 3; 4; 5;] |> checkIfAllPrime
// Error ["1 must be greater than 1"]
Expand Down
Loading
Loading