tag:blogger.com,1999:blog-5569894.post7482550673973570719..comments2023-11-08T13:18:07.006+00:00Comments on Distributed Memory: F# asynchrony and Task -> Task conversionSteve Gilhamhttp://www.blogger.com/profile/03622573187942388226noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-5569894.post-2511612908398550852013-08-27T14:46:42.602+01:002013-08-27T14:46:42.602+01:00Yes does the whole job of making them part of the ...Yes does the whole job of making them part of the Async infrastructure -- and there's a similar transformation to extend the FSharpx.Task module, which is where I hit the problem of needing to make this conversion. In either case, it's all variations on the same core theme.<br /><br />Exactly where to draw boundaries of small functions composed, or larger monolithic functions is one of these matters of style (if you only ever call a function in a composition, do you keep it as a separate concern or not?). For a blog post I'd rather give the smallest nuggets of functionality and let people weld them together as they see fit for their particular needs.Steve Gilhamhttps://www.blogger.com/profile/03622573187942388226noreply@blogger.comtag:blogger.com,1999:blog-5569894.post-63209073072081532822013-08-26T13:15:29.414+01:002013-08-26T13:15:29.414+01:00Or extend async {} so that you can directly use bo...Or extend async {} so that you can directly use both kinds of Task without Async.AwaitTask at all..<br /><br />[]<br />module Async =<br /> let inline AwaitUnitTask (task: Task) = <br /> // rethrow exception from preceding task if it fauled<br /> let continuation (t : Task) : unit =<br /> match t.IsFaulted with<br /> | true -> raise t.Exception<br /> | _ -> ()<br /> task.ContinueWith continuation |> Async.AwaitTask<br /><br /><br />type Microsoft.FSharp.Control.AsyncBuilder with<br /> member x.Bind (t : Task<'T>, f : 'T -> Async<'R>) : Async<'R> = x.Bind (Async.AwaitTask t, f)<br /><br /> member x.Bind (t : Task, f : unit -> Async) : Async = x.Bind (Async.AwaitUnitTask t, f)<br />Anonymousnoreply@blogger.com