Is there a way to look at the definition of the Async workflow? What goes under the hood that would make a line of code behave differently in there, than outside of it?
2 Answers
If by "the Async workflow", you mean the AsyncBuilder type which defines the behavior of async blocks, then you can find the definition in the control.fs file in the source distribution, in the source\fsharp\FSharp.Core folder.
The translation of a computation expression into method calls on the builder instance can be found in the F# spec.
3 Comments
Brian
+1 for the spec. Especially, if you understand how LINQ works in C# (syntax rewriting into method calls), you can grok how F# workflows work by translating into method calls on the builder object. If you're curious about the specific details of async, then look at control.fs in the source code.
akaphenom
where does one get the fs source from?
kvb
@akaphenom - The source comes with the F# 2.0 release for VS 2008 (microsoft.com/downloads/…). I'm not sure if it's also included in the VS 2010 installation out of the box...
Adding to kvb's advice, relevant Don's "Expert F#" chapter is available online:
It includes a short but informative "Under the Hood" section.