Slightly off topic, but I thought I'd mention that the latest release of F# (1.1.13.8) includes an API to access the implementation of syntax colorization, interactive type checking and some of the intellisense information in a file (not all intellisense information is currently propagated). In principle this should allow a good programmer to embed the F# interactive behaviour into other .NET-implemented editing environments. We've tested this by writing a micro sample using WinForms, but not a complete embedding into another editor.
The API is in FSharp.Compiler.dll, and the most important entry points are shown below.
If anyone starts a community project bsed on this I would strongly encourage you to host the project on CodePlex. Also, while the API below is expected to be largely stable, if you pick up a dependency on the API you should expect the possibility of a small number of changes and extensions to the API in each major revision of F#. Thus you should expect to have to release your project in source code form (to enable others to make changes to keep it in sync), and to aim to keep your code or community project up to date with each major release of F#. Ideally keep in touch with the F# team about the timing of new releases.
namespace Microsoft.FSharp.Compiler.SourceCodeServices
type InteractiveColorizer
with
/// Color a line of F# source code, starting with the given lexState. The lexState should be 0 for
/// the first line of text. Returns an array of ranges of the text and two enumerations categorizing the
/// tokens and characters covered by that range, i.e. TokenColorKind and TokenCharKind. The enumerations
/// are somewhat adhoc but useful enough to give good colorization options to the user in an IDE.
///
/// A new lexState is also returned. An IDE-plugin should in general cache the lexState
/// values for each line of the edited code.
static member ColorLine : line:string * LexState -> (LineRange * TokenColorKind * TokenCharKind) array * LexState
/// Same as ColorLine, but faster since only the resulting lexState is returned. Useful for colorizing
/// the invisible text leading up to the part of a file that is actually displayed.
static member ColorSkipLine : line:string * LexState -> LexState
end
type InteractiveChecker
with
/// Create an instance of an InteractiveChecker. Currently resources are not reclaimed.
static member Create : unit -> InteractiveChecker
/// Parse and (optionally) typecheck a source code file, returning a handle to the results of the parse including
/// the reconstructed types in the file
member ParseSource : source: string * options: ParseOptions -> ParseResults
end