Quotation Compilation library that uses FSharp.Compiler.Service
F# Other
Latest commit 545f94f Feb 2, 2017 @eiriktsarpalis committed on GitHub Merge pull request #16 from vasily-kirichenko/update-packages
Update packages
Failed to load latest commit information.
.paket Reconfigured Project for commandline building Aug 9, 2015
nuget add nuget package Dec 8, 2014
packages/NuGet.CommandLine/tools update packages Feb 1, 2017
src/QuotationCompiler update packages Feb 1, 2017
tests/QuotationCompiler.Tests copy FSharp.Core.optdata and FSharp.Core.sigdata to output directory Feb 2, 2017
.gitattributes Initial commit to add default .gitIgnore and .gitAttribute files. Nov 8, 2014
.gitignore Updated ignore Aug 9, 2015
.travis.yml update mono version Nov 23, 2014
QuotationCompiler.sln delete nuspec Jul 3, 2015
README.md add nuget package Dec 8, 2014
RELEASE_NOTES.md fix #11 Jul 9, 2015
appveyor.yml add build script Nov 23, 2014
paket.dependencies update packages Feb 1, 2017
paket.lock update packages Feb 1, 2017



A small library for compiling code quotations using the F# compiler service. Its primary functionality is transforming quotation trees to untyped ASTs used by the F# compiler. Since code is generated using the F# compiler proper, the end result is fully efficient and optimized.

Package available on NuGet.


#r "QuotationCompiler.dll"

open QuotationCompiler

let hello : unit -> unit = QuotationCompiler.ToFunc <@ printfn "Hello, world!" @>

hello ()


As can be expected, performance exceeds all other quotation evaluation libraries. Here is a benchmark for a tail recursive algorithm:

let sqrt (x : float) =
    let epsilon = 1e-10
    let rec approximate (y : float) =
        let y' = (y + x / y) / 2.
        if abs (y - y') < epsilon then y'
            approximate y'

    approximate x
Library Compilation time (cold) Compilation time (warm)
Native N/A N/A
Unquote 00:00:00.055 00:00:00.000
FSharp.Quotations.Evaluator 00:00:00.405 00:00:00.003
QuotationCompiler 00:00:05.068 00:00:00.161

Executing the compiled functions 10^6 times produced the following results:

Library Execution time GC gen0,1,2
Native 00:00:00.053 0,0,0
Unquote 00:01:46.675 9598,12,1
FSharp.Quotations.Evaluator 00:00:00.087 15,0,0
QuotationCompiler 00:00:00.053 0,0,0


The library currently has a few limitations

  • No support for dynamic assemblies. Quotations inherently belong to the runtime and ASTs are inherently static. It is impossible to compile quotations that reference types/code defined in F# interactive.
  • F# metadata issues. Things may break when referencing generic values, extension methods or CompiledName types.

Build Status

Head (branch master), Build & Unit tests

  • Windows/.NET Build status
  • Mac OS X/Mono 3.10 Build Status