In the application script hosting. How does tryfsharp.org work?

I am interested in the ability to have F # scripts in my application.

Something like tryfsharp.org would be great, in particular the Intellisense ability. Is there any of this on Github? How it works?

+6
source share
1 answer

Short answer

The code used for the first TryFSharp cut with F # 2, which includes Intellisense support, is available as a code drop . As an example, Rob Pickering created an online editor for Undertone . I suspect that the code used on the current TryFSharp site that uses F # 3 will pop up on time.

TryFSharp uses Silverlight to host the F # compiler in the client browser (F # is written to F #). You can also call an instance of the F # compiler, which runs on the server from the browser on demand, which is the approach adopted by TryFs.Net and Pit .

Longer answer

There are two sides to scripting:

  • Editing
  • Performance

F # already supports editing and executing (.fsx) script files through F # Interactive .

Editing F # Code

There is no shortage of external editors for F # code:

Support for Xamarin Studio, Emacs, and Vim is based on the F # Bindings project, which provides code completion. SharpDevelop uses the open source AvalonEdit and turns on syntax highlighting for F #. You can use AvalonEdit in your own projects, for example, the open source Refunctor project uses it to provide F # editing inside the Reflector.

There are also several new editors for F # on the horizon:

AvalonEdit is a good place to launch the built-in desktop editor. After you have chosen the editor environment, you need to choose between simple syntax highlighting or more complex integration using F # bindings. If you suspect that people will use an external editor, syntax highlighting may be sufficient.

Bring your own editor, probably the easiest place to start, which just stops running.

F # code execution

Parameters for executing F # code:

Compiling a snippet with F # CodeDOM:

open Microsoft.FSharp.Compiler.CodeDom open System.CodeDom.Compiler let compile snippet = use provider = new FSharpCodeProvider() let options = CompilerParameters(GenerateInMemory=true) provider.CompileAssemblyFromSource(options, [|snippet|]) let snippet = """ module Snippet let x = 1 """ let results = compile snippet 
+19
source

All Articles