I’m supposed to be writing, but…

Apologies in advance to Don Syme here.  I'm weak, and easily distracted. F# is my muse.

let WriteChaptersAsync (x) =
     async { use someBrain = Brain.OpenAndThink(sprintf "getIt.tmp" x)
     let! ideas = someBrain.ReadAsync(thoughts)
     let  ideas' = TransformIntoParagraphs(pages,x)
     use outStream = Brain.OpenAndWrite(sprintf "gotIt.done" x)
     do! outStream.WriteAsync(ideas')  }

let WriteChaptersAsync ( ) =
     printfn "WriteChatpersAsync...";
     let tasks = [ for x in 1 ..numPages -> WriteChaptersAsync(x) ]

     //realistically using Async.Future here, or maybe Async.Spawn...
     Async.Run (Async.Parallel tasks) | > ignore
     printfn "WriteChaptersAsync finished!";

Don Syme on F# Async Workflows on Ch9

Don Syme's WebLog on F# and Other Research Projects : Introducing F# Asynchronous Workflows

Skip to main content