I am developing WebSharper. Good question!
Example: compilation looks something like this:
a.dll: a.fs b.fs c.fs fsc ... a.dll.js: a.dll WebSharper.exe ..
When functions are annotated using [<JavaScript>] , which is an alias for [<ReflectedDefinition>] , the F # compiler not only compiles these functions in .NET IL, but also saves its syntax representation in the DLL metadata. This view is of the type Quotations.Expr and can be restored by reflection. See Quotations.DerivedPatterns.MethodWithReflectedDefinition .
Thus, WebSharper is the source for the source translator, and it is pretty straightforward (for example, it saves lambdas). In WebSharper 2.0, we have an intermediate language like Scheme, but that only helps optimize the generated code.
source share