CheckOptions options for InteractiveChecker

83 views
Skip to first unread message

Michael P

unread,
Jan 3, 2012, 11:23:47 PM1/3/12
to fsharp-o...@googlegroups.com
Can someone please elaborate on the details of the following record. What are the projects options? What are the resolution rules of compiler?
Motivation & scope: To understand better the possible usages of InteractiveChecker.
I hope that the answer will be also useful for other users.

Relative path: fsharpPowerPack-src\compiler\2.0\Aug2011.1\src\fsharp\vs\service.fsi  (line 232)

type (* internal *) CheckOptions = 
    { 
      ProjectFileName: string;  // JAF: Can this reduce to just project directory? No, because there may be two projects in the same directory.
      ProjectFileNames: string array;
      ProjectOptions: string array;
      /// When true, the typechecking environment is known a priori to be incomplete. 
      /// This can happen, for example, when a .fs file is opened outside of a project.
      /// It may be appropriate, then, to not show error messages related to type checking
      /// since they will just be noise.
      IsIncompleteTypeCheckEnvironment : bool;
      /// When true, use the reference resolution rules for scripts rather than the rules for compiler.
      UseScriptResolutionRules : bool;
    }

Regards,
Michael

Don Syme

unread,
Jan 4, 2012, 8:22:40 AM1/4/12
to fsharp-o...@googlegroups.com

Hi Michael,

 

As a starting point, see the use of this type in the SimpleSourceCodeServices API in

                src\fsharp\FSharp.Compiler.Silverlight\fsisilverlight.fs

 

and the two samples that are built on that in

                samples\SilverlightHostedCompilerServices

 

That SimpleSourceCodeServices API is only included in the Silverlight-hosted compiler (though there is no real reason why it should not be included in the .NET 4.0 version of FSharp.Compiler.dll, though some adjustments would be needed). 

 

It allows for

-                 tokenization

-                 brace-matching

-                 type-checking

-                 compilation-to-static-assembly

-                 compilation-to-dynamic-assembly-without-execution-of-top-level-bindings

-                 compilation-to-dynamic-assembly-with-execution-of-top-level-bindings-and-capturing-stdin-stdout-stderr

 

of a single script file. This is generally done without "project context" (additional project options or DLL references) and is done synchronously (though can be invoked from a background compilation thread or compilation agent) 

 

The options are usually given like this:

 

        let options = { ProjectFileName="console.fsproj";

                        ProjectFileNames=[| "example.fsx" |];

                        ProjectOptions=[| |];

                        IsIncompleteTypeCheckEnvironment=false;

                        UseScriptResolutionRules=true }

 

In some of cases, like compilation, "project options" can be given to indicate a set of additional command line options. These allow, for example, to reference a different mscorlib.dll and FSharp.Core.dll. Despite the comments in fsisilverlight.fs, this means the API can be used to compile scripts to .NET and other kinds of binaries.

 

The SimpleSourceCodeServices API is not as yet suitable for compiling projects. The F# MonoDevelop source code gives a guide to how the underlying compiler functionality can be used for more complex cases like that.

 

I'll aim to add some additional documentation to these types and methods.

 

Thanks

Don

--
You received this message because you are subscribed to the Google
Groups "FSharp Open Source Community" group.
To post to this group, send email to fsharp-o...@googlegroups.com
To unsubscribe from this group, send email to
fsharp-opensou...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/fsharp-opensource?hl=en

Michael

unread,
Jan 4, 2012, 9:52:59 AM1/4/12
to fsharp-o...@googlegroups.com
I tried to instantiate the InteractiveChecker in an unit test environment but got numerous exceptions. I did not investigate them yet but i assume that most of them has to do with the lack of the dispatcher/message loop. I like the pointer that you provided. I am going to check it more thoroughly.  I guess this is the the best and the most not intrusive way to start. A simple service with features that you've described sounds very good.

Regarding the CheckOptions record, I think that it would make it a great deal easier if this record had a default set of options so user could use the "with" syntax and code completion like 
let opt = {CheckOptions.defaults with IsIncompleteTypeCheckEnvironment=false }
Isn't it?

--

Michael Pavlovsky

panesofglass

unread,
Feb 24, 2013, 10:54:18 PM2/24/13
to fsharp-o...@googlegroups.com
Don:

Did you ever happen to add the additional documentation somewhere?

Thanks,
Ryan
Reply all
Reply to author
Forward
0 new messages