f#-interactive

How does F# Interactive #I command know about project path?

偶尔善良 提交于 2019-12-20 20:16:10
问题 Here is the scenario: Open Visual Studio. This was done in VS2010 Pro. Open F# Interactive within Visual Studio Open project with fsx file Note: Project and fsx file are in E:\<directories>\fsharp-tapl\arith Send commands to F# Interactive from fsx file > System.Environment.CurrentDirectory;; val it : string = "C:\Users\Eric\AppData\Local\Temp" I was not expecting a Temp directory but it makes sense. > #r @"arith.exe" Examples.fsx(7,1): error FS0082: Could not resolve this reference. Could

How does fsi.ShowDeclarationValues work?

孤街醉人 提交于 2019-12-20 04:34:43
问题 According to the MSDN documentaion: When set to false, disables the display of declaration values in the output of the interactive session. However, the following sample interactive session seems to contradict that summary. > let x = 42;; val x : int = 42 > fsi.ShowDeclarationValues <- false;; val it : unit = () > let y = 42;; val y : int I was not expecting the last line above. Have I misunderstood something? Can anyone confirm if this is a bug? Thanks. 回答1: Daniel is correct - this disables

Bitmap image manipulation

流过昼夜 提交于 2019-12-20 02:39:10
问题 I want to replace GetPixel and SetPixel using LockBits method, so I came across this F# lazy pixels reading open System.Drawing open System.Drawing.Imaging let pixels (image:Bitmap) = let Width = image.Width let Height = image.Height let rect = new Rectangle(0,0,Width,Height) // Lock the image for access let data = image.LockBits(rect, ImageLockMode.ReadOnly, image.PixelFormat) // Copy the data let ptr = data.Scan0 let stride = data.Stride let bytes = stride * data.Height let values : byte[]

scripts don't recognize FSharp.Data

天大地大妈咪最大 提交于 2019-12-19 13:38:13
问题 Somewhat of a F# beginner. I'm trying to test out some of my XmlTypeProvider code in the interactive window by first entering it in a script (fsx) file. The script file won't recognize the following open FSharp.Data // gives "The namespace or module 'FSharp' is not defined" Everything has been added to reference, and .fs files seem to not have any problems finding the XmlTypeProvider reference but for some reason, a script in the same project does not. I even got the code to work in a .fs

How to generate the F# type signature similar to FSI in my own code?

主宰稳场 提交于 2019-12-18 15:09:30
问题 If one uses the F# Interactive Shell (FSI), the inferred expression type (signature) is printed to the console along with its value: val it : int * string * float = (42, "Hello F#", 42.0) How can I mimick the same behaviour in my own code, e.g. to get the inferred types as string for a F# expression? I don't need to dynamically evaluate any F# expressions, the expressions are known in compile time and are part of my (static) F# code. I need this feature to be able to mimick the FSI output in

F# programmatically running .fsx script file

大憨熊 提交于 2019-12-18 13:39:15
问题 I'm sure this must be something really easy, but I can't seem to make it work. Let's say I have an .fsx script file and want to cause it to be executed programmatically. I'm guessing someone must have blogged about this at some point, but I can't seem to find an example that performs my simple scenario. Basically, I want to programmatically duplicate what happens when you right click on an .fsx file and choose "Run with F# Interactive..." 回答1: As asked in a comment, you can set

fsx script referencing a dll referencing many dll

爷,独闯天下 提交于 2019-12-18 13:10:03
问题 What kind of strategy do I have for the following problem. I want to use a simple class inside a dll, which has link to various dlls, of various versions etc. As a fsx file, my script show no error. but upon running it in fsharp interactive, it tells me error FS0074: The type referenced through 'theTypeIWantToUse' is defined in an assembly that is not referenced. You must add a reference to assembly 'Assembly'. Of course the assembly is referenced, so I imagine I need to add references to

Using NLog with F# Interactive in Visual Studio - Need documentation

ⅰ亾dé卋堺 提交于 2019-12-18 04:23:24
问题 I have a need to capture the input and output of F# functions when using F# Interactive. I am able to get NLog to work just fine when the program is run under Visual Studio using F5 or Ctrl-F5. Also the same methods that contain statements to output to the log work just fine and are called when invoked via F# Interactive; just nothing in the log file. I also tried the following with F# Interactive to setup references to NLog and still nothing in the log when run from F# Interactive. #I @"..

Need help regarding Async and fsi

元气小坏坏 提交于 2019-12-18 04:23:11
问题 I'd like to write some code that runs a sequence of F# scripts (.fsx). The thing is that I could have literally hundreds of scripts and if I do that: let shellExecute program args = let startInfo = new ProcessStartInfo() do startInfo.FileName <- program do startInfo.Arguments <- args do startInfo.UseShellExecute <- true do startInfo.WindowStyle <- ProcessWindowStyle.Hidden //do printfn "%s" startInfo.Arguments let proc = Process.Start(startInfo) () scripts |> Seq.iter (shellExecute "fsi") it

How do I customize output of a custom type using printf?

我们两清 提交于 2019-12-17 11:23:12
问题 I've read through a good chunk of Expert F# and am working on building an actual application. While debugging, I've grown accustomed to passing fsi commands like this to make things legible in the repl window: fsi.AddPrinter(fun (x : myType) -> myType.ToString()) I would like to extend this to work with the printf formatter, so I could type e.g. printf "%A" instanceOfMyType and control the output for a custom type. The book implies that this can be done (p 93, "Generic structural formatting