Skip to content
Merged
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
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
4 changes: 2 additions & 2 deletions gitbook/resultOption/ce.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ let add x y z = x + y + z

let addResult : Result<int option, string> = resultOption {
let! x = Ok (Some 30)
and! y = Error "Oops 1"
and! z = Error "Oops 2"
let! y = Error "Oops 1"
let! z = Error "Oops 2"
return add x y z
}
// Error "Oops 1"
Expand Down
8 changes: 0 additions & 8 deletions src/FsToolkit.ErrorHandling/AsyncResultCE.fs
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,6 @@ module AsyncResultCE =
) : Async<Result<'okOutput, 'error>> =
AsyncResult.map f x

member inline _.MergeSources
(
t1: Async<Result<'leftOk, 'error>>,
t2: Async<Result<'rightOk, 'error>>
) : Async<Result<'leftOk * 'rightOk, 'error>> =
AsyncResult.zip t1 t2


/// <summary>
/// Method lets us transform data types into our internal representation. This is the identity method to recognize the self type.
///
Expand Down
30 changes: 0 additions & 30 deletions src/FsToolkit.ErrorHandling/OptionCE.fs
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,6 @@ module OptionCE =
) : 'output option =
Option.map f (Option.ofObj x)

member inline _.MergeSources
(
option1: 'left option,
option2: 'right option
) : ('left * 'right) option =
Option.zip option1 option2

/// <summary>
/// Method lets us transform data types into our internal representation. This is the identity method to recognize the self type.
///
Expand All @@ -137,29 +130,6 @@ module OptionExtensionsLower =

member inline _.Source(m: string) : string option = Option.ofObj m

member inline _.MergeSources
(
nullableObj1: 'left,
option2: 'right option
) : ('left * 'right) option =
Option.zip (Option.ofObj nullableObj1) option2


member inline _.MergeSources
(
option1: 'left option,
nullableObj2: 'right
) : ('left * 'right) option =
Option.zip (option1) (Option.ofObj nullableObj2)


member inline _.MergeSources
(
nullableObj1: 'left,
nullableObj2: 'right
) : ('left * 'right) option =
Option.zip (Option.ofObj nullableObj1) (Option.ofObj nullableObj2)

[<AutoOpen>]
module OptionExtensions =
open System
Expand Down
7 changes: 0 additions & 7 deletions src/FsToolkit.ErrorHandling/ResultCE.fs
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,6 @@ module ResultCE =
) : Result<'okOutput, 'error> =
Result.map f x

member inline _.MergeSources
(
left: Result<'left, 'error>,
right: Result<'right, 'error>
) : Result<'left * 'right, 'error> =
Result.zip left right

/// <summary>
/// Method lets us transform data types into our internal representation. This is the identity method to recognize the self type.
///
Expand Down
7 changes: 0 additions & 7 deletions src/FsToolkit.ErrorHandling/ResultOptionCE.fs
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,6 @@ module ResultOptionCE =
) : Result<'U option, 'TError> =
ResultOption.map binder resultOpt

member inline _.MergeSources
(
left: Result<'left option, 'error>,
right: Result<'right option, 'error>
) : Result<('left * 'right) option, 'error> =
ResultOption.zip left right

member inline _.Source(result: Result<'ok option, 'error>) : Result<'ok option, 'error> =
result

Expand Down
13 changes: 0 additions & 13 deletions src/FsToolkit.ErrorHandling/ValueOptionCE.fs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ module ValueOptionCE =
|> ValueOption.ofObj
|> ValueOption.map f

member inline _.MergeSources(option1, option2) = ValueOption.zip option1 option2

/// <summary>
/// Method lets us transform data types into our internal representation. This is the identity method to recognize the self type.
///
Expand All @@ -127,17 +125,6 @@ module ValueOptionExtensionsLower =
m
|> ValueOption.ofObj

member inline _.MergeSources(nullableObj1, option2) =
ValueOption.zip (ValueOption.ofObj nullableObj1) option2


member inline _.MergeSources(option1, nullableObj2) =
ValueOption.zip (option1) (ValueOption.ofObj nullableObj2)


member inline _.MergeSources(nullableObj1, nullableObj2) =
ValueOption.zip (ValueOption.ofObj nullableObj1) (ValueOption.ofObj nullableObj2)

[<AutoOpen>]
module ValueOptionExtensions =
open System
Expand Down
168 changes: 0 additions & 168 deletions tests/FsToolkit.ErrorHandling.Tests/AsyncResultCE.fs
Original file line number Diff line number Diff line change
Expand Up @@ -500,173 +500,6 @@ let toTaskResult v =
|> Task.FromResult
#endif

let ``AsyncResultCE applicative tests`` =
testList "AsyncResultCE applicative tests" [
testCaseAsync "Happy Path AsyncResult"
<| async {
let! actual =
asyncResult {
let! a = AsyncResult.retn 3
and! b = AsyncResult.retn 2
and! c = AsyncResult.retn 1
return a + b - c
}

Expect.equal actual (Ok 4) "Should be ok"
}

#if !FABLE_COMPILER

testCaseAsync "Happy Path TaskResult"
<| async {
let! actual =
asyncResult {
let! a = toTaskResult 3
and! b = toTaskResult 2
and! c = toTaskResult 1
return a + b - c
}

Expect.equal actual (Ok 4) "Should be ok"
}

#endif

testCaseAsync "Happy Path Result"
<| async {
let! actual =
asyncResult {
let! a = Result.Ok 3
and! b = Result.Ok 2
and! c = Result.Ok 1
return a + b - c
}

Expect.equal actual (Ok 4) "Should be ok"
}

testCaseAsync "Happy Path Choice"
<| async {
let! actual =
asyncResult {
let! a = Choice1Of2 3
and! b = Choice1Of2 2
and! c = Choice1Of2 1
return a + b - c
}

Expect.equal actual (Ok 4) "Should be ok"
}

// Cannot get this to compile properly
testCaseAsync "Happy Path Async"
<| async {
let! actual =
asyncResult {
let! a = Async.singleton 3 //: Async<int>
and! b = Async.singleton 2 //: Async<int>
and! c = Async.singleton 1 //: Async<int>
return a + b - c
}

Expect.equal actual (Ok 4) "Should be ok"
}

testCaseAsync "Happy Path 2 Async"
<| async {
let! actual =
asyncResult {
let! a = Async.singleton 3 //: Async<int>
and! b = Async.singleton 2 //: Async<int>
return a + b
}

Expect.equal actual (Ok 5) "Should be ok"
}

#if !FABLE_COMPILER

testCaseAsync "Happy Path 2 Task"
<| async {
let! actual =
asyncResult {
let! a = Task.FromResult 3
and! b = Task.FromResult 2
return a + b
}

Expect.equal actual (Ok 5) "Should be ok"
}

#endif

testCaseAsync "Happy Path Result/Choice/AsyncResult"
<| async {
let! actual =
asyncResult {
let! a = Ok 3
and! b = Choice1Of2 2

and! c =
Ok 1
|> Async.singleton

return a + b - c
}

Expect.equal actual (Ok 4) "Should be ok"
}

testCaseAsync "Fail Path Result"
<| async {
let expected = Error "TryParse failure"

let! actual =
asyncResult {
let! a = Ok 3
and! b = Ok 2
and! c = expected
return a + b - c
}

Expect.equal actual expected "Should be Error"
}

testCaseAsync "Fail Path Choice"
<| async {
let errorMsg = "TryParse failure"

let! actual =
asyncResult {
let! a = Choice1Of2 3
and! b = Choice1Of2 2
and! c = Choice2Of2 errorMsg
return a + b - c
}

Expect.equal actual (Error errorMsg) "Should be Error"
}

testCaseAsync "Fail Path Result/Choice/AsyncResult"
<| async {
let errorMsg = "TryParse failure"

let! actual =
asyncResult {
let! a = Choice1Of2 3

and! b =
Ok 2
|> Async.singleton

and! c = Error errorMsg
return a + b - c
}

Expect.equal actual (Error errorMsg) "Should be Error"
}
]


let ``AsyncResultCE Stack Trace Tests`` =

Expand Down Expand Up @@ -743,7 +576,6 @@ let allTests =
``AsyncResultCE try Tests``
``AsyncResultCE using Tests``
``AsyncResultCE loop Tests``
``AsyncResultCE applicative tests``
``AsyncResultCE Stack Trace Tests``
``AsyncResultCE inference checks``
]
Loading