mirror of
https://github.com/Smaug123/WoofWare.PawPrint
synced 2025-10-05 14:18:40 +00:00
Add Result module (#29)
This commit is contained in:
19
WoofWare.PawPrint/Result.fs
Normal file
19
WoofWare.PawPrint/Result.fs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace WoofWare.PawPrint
|
||||
|
||||
[<RequireQualifiedAccess>]
|
||||
module internal Result =
|
||||
|
||||
let allOkOrError<'a, 'b> (rs : Result<'a, 'b> list) : Result<'a list, 'a list * 'b list> =
|
||||
let rec go (oks : 'a list) (errs : 'b list) rs =
|
||||
match rs with
|
||||
| Ok ok :: rest -> go (ok :: oks) errs rest
|
||||
| Error e :: rest -> go oks (e :: errs) rest
|
||||
| [] ->
|
||||
let oks = List.rev oks
|
||||
|
||||
if List.isEmpty errs then
|
||||
Ok oks
|
||||
else
|
||||
Error (oks, List.rev errs)
|
||||
|
||||
go [] [] rs
|
@@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<WoofWareMyriadPluginsVersion>7.0.7</WoofWareMyriadPluginsVersion>
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="Tuple.fs" />
|
||||
<Compile Include="Result.fs" />
|
||||
<Compile Include="StringToken.fs" />
|
||||
<Compile Include="Tokens.fs" />
|
||||
<Compile Include="TypeRef.fs" />
|
||||
|
Reference in New Issue
Block a user