diff --git a/src/AsyncWriterResult/Library.fs b/src/AsyncWriterResult/Library.fs index 474e1ce..a951bdb 100644 --- a/src/AsyncWriterResult/Library.fs +++ b/src/AsyncWriterResult/Library.fs @@ -1,6 +1,8 @@ [] module AsyncWriterResult +open System.Threading.Tasks + module Async = @@ -261,6 +263,7 @@ type AsyncWriterResultBuilder() = member __.Bind(m, f) = AsyncWriterResult.bind f m member __.Zero() = __.Return() member __.Source(x: Async>>) = x + member __.Source(x: Task>>) = x |> Async.AwaitTask let asyncWriterResult = AsyncWriterResultBuilder() @@ -270,6 +273,7 @@ module AsyncWriterResultBuilderExtensions = member __.Source(x: Result<'a, 'b>) = x |> AsyncWriter.retn member __.Source(x: Writer<'w, 't>) = x |> Writer.map Ok |> Async.retn member __.Source(x: Async<'t>) = x |> Async.map WriterResult.retn + member __.Source(x: Task<'t>) = x |> Async.AwaitTask |> Async.map WriterResult.retn [] module AsyncWriterResultBuilderExtensionsHighPriority = @@ -277,3 +281,5 @@ module AsyncWriterResultBuilderExtensionsHighPriority = member __.Source(x: Writer<'w, Result<'a, 'b>>) = x |> Async.retn member __.Source(x: Async>) = x |> Async.map Writer.retn member __.Source(x: Async>) = x |> AsyncWriter.map Result.retn + member __.Source(x: Task>) = x |> Async.AwaitTask |> Async.map Writer.retn + member __.Source(x: Task>) = x |> Async.AwaitTask |> AsyncWriter.map Result.retn diff --git a/src/AsyncWriterResult/TaskWriterResult.fs b/src/AsyncWriterResult/TaskWriterResult.fs index 851dac6..c972b8e 100644 --- a/src/AsyncWriterResult/TaskWriterResult.fs +++ b/src/AsyncWriterResult/TaskWriterResult.fs @@ -113,6 +113,7 @@ module TaskWriterResult = member __.Bind(m, f) = bind f m member __.Zero() = __.Return() member __.Source(x: Task>>) = x + member __.Source(x: Async>>) = x |> Async.StartAsTask let taskWriterResult = TaskWriterResultBuilder() @@ -122,10 +123,13 @@ module TaskWriterResult = member __.Source(x: Result<'a, 'b>) = x |> TaskWriter.retn member __.Source(x: Writer<'w, 't>) = x |> Writer.map Ok |> Task.retn member __.Source(x: Task<'t>) = x |> Task.map WriterResult.retn + member __.Source(x: Async<'t>) = x |> Async.StartAsTask |> Task.map WriterResult.retn [] module TaskWriterResultBuilderExtensionsHighPriority = type TaskWriterResultBuilder with member __.Source(x: Writer<'w, Result<'a, 'b>>) = x |> Task.retn member __.Source(x: Task>) = x |> Task.map Writer.retn - member __.Source(x: Task>) = x |> TaskWriter.map Result.retn \ No newline at end of file + member __.Source(x: Task>) = x |> TaskWriter.map Result.retn + member __.Source(x: Async>) = x |> Async.StartAsTask |> Task.map Writer.retn + member __.Source(x: Async>) = x |> Async.StartAsTask |> TaskWriter.map Result.retn \ No newline at end of file