The tasks of kind you outlined in your question may be performed with tools provided within Microsoft.FSharp.Compiler.Interactive
namespace, in particular, with the help of type FsiEvaluationSession
of Microsoft.FSharp.Compiler.Interactive.Shell
.
This gist authored by Ryan Riley demoes exactly your scenario using a thin wrapper type FSharpEngine
over FsiEvaluationSession
, making programmatic use of fsi
as convenient as:
....
let engine = new FSharpEngine()
engine.Execute("<some F# code>") |> processOutput
....
engine.Dispose()