Everywhere I use a task computational expression 2.0.1 gives a build error:
error FS0708: This control construct may only be used if the computation expression builder defines a 'Bind' method
The same code works in 2.0.0 - the only change is to update the Giraffe package to 2.0.1
Hi, yeah in 2.0.0 there was a place where I forgot to open the new V2 namespace for the TaskCE. You should do the same if working with tasks in Giraffe >= 2.0.1:
open FSharp.Control.Tasks.V2.ContextInsensitive
The change of namespace is a side effect of upgrading to TaskBuilder.fs version 2.
Hope that helps!
A coworker of mine just ran into this and it took us a while to find this issue and resolve it - is there anything that can be done to improve this error message? If the task CE were unavailable we would have known what to fix but the message about Bind not being available is very confusing.
Can the docs be updated to reflect that explicitly opening this module is required? This issue led me to look at the deprecated Giraffe.Tasks project, which explains to open the third-party module now, but the Giraffe docs imply you only need to open the module outside the context of Giraffe.
Updating the docs is certainly a good idea, however I think this can be fixed by deleting this line of code which I think is redundant at this point now.
Initially I overrode the task {} CE with this line of code in order to ensure that all task {} usage in Giraffe (which is always a web context) to use the ContextInsensitive version, but afterwards I found out that in ASP.NET Core there is no difference between context sensitive and context insensitive tasks anymore. They always behave context insensitive, even if you open the wrong namespace.
With that information I am pretty confident that this can be removed now and I hope that removing it will basically start underlining the task{} CE in anybody's code unless they have openend the namespace explicitly (as it should be). If it is not open yet then IntelliSense should suggest the correct version (V2) hopefully, but adding that to the docs is useful too.
I anticipate a new release soon with some improvements to the view engine as well, so will try to roll this out all together very soonish!
Ok, both changes are ready for the next release. Thanks for bringing this to attention!
Most helpful comment
Hi, yeah in 2.0.0 there was a place where I forgot to open the new V2 namespace for the TaskCE. You should do the same if working with tasks in Giraffe >= 2.0.1:
The change of namespace is a side effect of upgrading to TaskBuilder.fs version 2.
Hope that helps!