.simulate()method should return the results of the Q# function or operation: https://github.com/microsoft/Quantum/blob/67f75e857c26c68168c0d404dc879abeee1682dd/samples/getting-started/intro-to-iqsharp/Notebook.ipynb#L346
.simulate()method in Python returns a value, while the
.Run()method in C# host programs returns a task that needs to be awaited on. We're in the process of clarifying this in documentation, so we really appreciate the feedback! 💕
@eginez Cool that you've looked at the compiler code! Let me give what I hope are some helpful pointers where to find things:
The output of the compiler right now is binary json (that may change in the future) and/or a dll that contains the same as resource (that might also change). Both at the moment contain the data structures here: https://github.com/microsoft/qsharp-compiler/blob/master/src/QsCompiler/DataStructures/SyntaxTree.fs
That output can be loaded by the compiler e.g. via the CompilationLoader: https://github.com/microsoft/qsharp-compiler/blob/bd09e7c63adf0d9420399c451d2e4a2e0c6b8479/src/QsCompiler/Compiler/CompilationLoader.cs#L747.
The command line compiler (https://github.com/microsoft/qsharp-compiler/tree/master/src/QsCompiler/CommandLineTool) allows to pass arbitrary .NET Core dlls via the handle --load path/to/your/dll that are invoked at the end of the compilation process. Any class implementing IRewriteStep in that dll will be executed as part of the compilation process (at the end of it). An example that invokes the C# generation in this way can be found here: https://github.com/microsoft/qsharp-compiler/blob/master/src/QsCompiler/TestTargets/Simulation/Target/Program.cs
It would be terrific to get some additional optimizations! Sounds like you have already found the project that one of my interns (Rory Soiffer) started this summer: https://github.com/microsoft/qsharp-compiler/tree/master/src/QsCompiler/Optimizations/OptimizingTransformations. I am happy to assist with pointers and such on how to add more! :)