PM> Install-Package FSharp.Quotations.Evaluator
This component is an F# quotations evaluator, implemented by compiling to LINQ expression trees.
For simple expression-based scenarios you may be able to simply use the method
FSharp.Linq.RuntimeHelpers.LeafExpressionConverter.EvaluateQuotation from `
However that component has restrictions in the quotations accepted - for example, statements such as while-loops are not accepted. This component accepts more quotations (including those involving statements), though some restrictions remain. Please help by contributing additional functionality to lift remaining restrictions.
Performance of generated code is generally OK though not as good as F# compiled code, expecially for recursive functions.
However it is still good enough for many purposes of dynamic code generation. Contributions to improve performance are welcome.
The component requires .NET 4.x. It is not usable on mobile devices or portable profiles, where code generation APIs are not available.
This example demonstrates using a function defined in this sample library.
1: 2: 3: 4: 5: 6: 7: 8:
The library comes with comprehensible documentation.
It can include a tutorials automatically generated from
*.fsx files in the content folder.
The API reference is automatically generated from Markdown comments in the library implementation.
Tutorial contains a further explanation of this sample library.
API Reference contains automatically generated documentation for all types, modules and functions in the library. This includes additional brief samples on using most of the functions.
The project is hosted on GitHub where you can report issues, fork the project and submit pull requests. If you're adding new public API, please also consider adding samples that can be turned into a documentation. You might also want to read library design notes to understand how it works.
The library is available under Public Domain license, which allows modification and redistribution for both commercial and non-commercial purposes. For more information see the License file in the GitHub repository.
static member CompileUntyped : Expr -> obj
static member Evaluate : Expr<'T> -> 'T
static member EvaluateUntyped : Expr -> obj
static member private EvaluateUntypedUsingQueryApproximations : Expr -> obj
static member ToLinqExpression : Expr -> Expression