Comments (9)
Sounds like a good addition!
from fstoolkit.errorhandling.
We have a function for that ofTaskAction .
from fstoolkit.errorhandling.
I tried that, this is the error I get:
Lightning.fs(237,94):
error FS0001: The type 'unit' is not compatible with the type 'Task' [Backend.fsproj]
Lightning.fs(237,13):
error FS0041: A unique overload for method 'Bind' could not be determined based on type information prior to this program point. A type annotation may be needed.
Candidates:
member AsyncResultBuilder.Bind : async':Async<'T> * binder:('T -> Async<Result<'U,'TError>>) -> Async<Result<'U,'TError>>,
member AsyncResultBuilder.Bind : asyncResult:Async<Result<'T,'TError>> * binder:('T -> Async<Result<'U,'TError>>) -> Async<Result<'U,'TError>>,
member AsyncResultBuilder.Bind : result:Choice<'T,'TError> * binder:('T -> Async<Result<'U,'TError>>) -> Async<Result<'U,'TError>>,
member AsyncResultBuilder.Bind : result:Result<'T,'TError> * binder:('T -> Async<Result<'U,'TError>>) -> Async<Result<'U,'TError>>,
member AsyncResultBuilder.Bind : task:Task * binder:(unit -> Async<Result<'T,'TError>>) -> Async<Result<'T,'TError>>, member AsyncResultBuilder.Bind : task:Task<'T> * binder:('T -> Async<Result<'U,'TError>>) -> Async<Result<'U,'TError>>,
member AsyncResultBuilder.Bind : taskResult:Task<Result<'T,'TError>> * binder:('T -> Async<Result<'U,'TError>>) -> Async<Result<'U,'TError>> [Backend.fsproj]
from fstoolkit.errorhandling.
let me prepare a complete example...
from fstoolkit.errorhandling.
Actually, I get an error even with this:
namespace Lightning
open FsToolkit.ErrorHandling
module Lightning =
let Test () =
asyncResult {
do! async { return (Ok "test") }
return ()
}
the error is
Lightning.fs(8,13): error FS0041: No overloads match for method 'Bind'. The available overloads are shown below. [Backend.fsproj]
Possible overload: 'member AsyncResultBuilder.Bind : asyncResult:Async<Result<'T,'TError>> * binder:('T -> Async<Result<'U,'TError>>) -> Async<Result<'U,'TError>>'. Type constraint mismatch. The type 'unit -> Async<Result<unit,'c>>' is not compatible with type 'string -> Async<Result<'a,'b>>' .
Possible overload: 'member AsyncResultBuilder.Bind : taskResult:System.Threading.Tasks.Task<Result<'T,'TError>> * binder:('T -> Async<Result<'U,'TError>>) -> Async<Result<'U,'TError>>'. Type constraint mismatch. The type 'Async<Result<string,'c>>' is not compatible with type 'System.Threading.Tasks.Task<Result<'a,'b>>' .
Possible overload: 'member AsyncResultBuilder.Bind : result:Result<'T,'TError> * binder:('T -> Async<Result<'U,'TError>>) -> Async<Result<'U,'TError>>'. Type constraint mismatch. The type 'Async<Result<string,'c>>' is not compatible with type 'Result<'a,'b>' .
Possible overload: 'member AsyncResultBuilder.Bind : result:Choice<'T,'TError> * binder:('T -> Async<Result<'U,'TError>>) -> Async<Result<'U,'TError>>'. Type constraint mismatch. The type 'Async<Result<string,'c>>' is not compatible with type 'Choice<'a,'b>' .
Possible overload: 'member AsyncResultBuilder.Bind : task:System.Threading.Tasks.Task * binder:(unit -> Async<Result<'T,'TError>>) -> Async<Result<'T,'TError>>'. Type constraint mismatch. The type 'Async<Result<string,'a>>' is not compatible with type 'System.Threading.Tasks.Task' .
Possible overload: 'member AsyncResultBuilder.Bind : task:System.Threading.Tasks.Task<'T> * binder:('T -> Async<Result<'U,'TError>>) -> Async<Result<'U,'TError>>'. Type constraint mismatch. The type 'Async<Result<string,'b>>' is not compatible with type 'System.Threading.Tasks.Task<'a>' .
Possible overload: 'member AsyncResultBuilder.Bind : async':Async<'T> * binder:('T -> Async<Result<'U,'TError>>) -> Async<Result<'U,'TError>>'. Type constraint mismatch. The type 'unit -> Async<Result<unit,'d>>' is not compatible with type 'Result<string,'a> -> Async<Result<'b,'c>>'
Is this not compatible with F# 4.5?
from fstoolkit.errorhandling.
Hmm we have a test that does bind against a unit task.
FsToolkit.ErrorHandling/tests/FsToolkit.ErrorHandling.Tests/AsyncResultCE.fs
Lines 148 to 154 in e9e05ba
Is this not compatible with F# 4.5?
Version 1.2.6 requires FSharp 4.6.2.
from fstoolkit.errorhandling.
It doesn't look like there's a good reason to not drop the minimum required FSharp.Core version, I'll open a PR for that.
from fstoolkit.errorhandling.
namespace Lightning
open FsToolkit.ErrorHandling
module Lightning =
let Test () =
asyncResult {
do! async { return (Ok "test") }
return ()
}
do!
is invalid here since you're trying to bind against something that has data. In your case the value "Test"
. You have two options.
Ignore the result:
let! _ = async { return Ok "test" }
or have the value be a unit:
do! async { return Ok () }
from fstoolkit.errorhandling.
Aaaah, thank you so much! It makes sense, I get it. Indeed I would appreciate if the min version was F# 4.5, since that is what the Mono packages for Ubuntu ships.
from fstoolkit.errorhandling.
Related Issues (20)
- Worried about the Diamond dependency problem HOT 6
- Documentation for Validation operators mentions Bind (>>=), but the library doesn't implement it HOT 1
- Should List.sequenceValidationA preserve order? HOT 2
- FSharp.Core version warning (net7.0) HOT 14
- Make Result.defaultWith accept error, or remove it HOT 2
- Overload issues with TaskResult on generic functions HOT 2
- Add Option.ofPair HOT 5
- Add asyncValidation CE, or make asyncResult (and result?) CEs work with 'and!' HOT 4
- Can we reinstate `TaskResult.foldResult` and the like? HOT 4
- Add Light/Dark Theme Toggle to Gitbook Docs
- Support ValueOption in FsToolkit.Errorhandling.asyncOption HOT 3
- Support TaskValidation to match AsyncValidation HOT 2
- Binding Async<'T option * 'T option> to AsyncValidation is having overload errors HOT 1
- Common Language Runtime detected an invalid program HOT 2
- TaskOption/TaskResult defaultValue and defaultWith
- Support requireValueSome and requireValueNone in Result, TaskResult and AsyncResult
- Async/Job/Task wrapped result + require functions helpers
- feat(Seq): Add sequenceResultA HOT 6
- Readme video unavailable HOT 1
- usage with npgsql HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fstoolkit.errorhandling.