Reputation: 3153
Am I able to script macros here? Maybe process some text? I may be interest in learning F# if this window provided the ability to process the current document, etc.
I have googled and found tutorials on learning F#, writing programs in F#, but nothing on what the F# interactive window is good for in VS.
EDIT: Sounds like a rant yes. Is it? No. I love scripting. I just wrote a ruby script to implement an interface on a bunch of existing POCO's, that I couldn't easily figure out how to do with with ReSharper. I was thinking that if there was an interactive ruby console that could work with the current document(s) it would have made that task much easier. Then I got thinking that maybe that the F# console was what I was looking for, and it would be learning F# for.
Upvotes: 2
Views: 1412
Reputation: 14057
As others have pointed out, the main purpose of the F# Interactive windows is as a REPL for F# development. I find it useful for other tasks though too - you can use it as a sophisticated calculator, you can open files and process text and do many of the kinds of things you might use a bash window for on unix.
I have experimented a bit with accessing the Visual Studio Automation APIs from F# Interactive as described in this blog post. This is clearly not what FSI was originally intended for but it does make some of the things you seem to be interested in possible. I think it would be useful if this was directly supported in FSI but as it is I've found it a bit clunky to be really useful so far.
Upvotes: 2
Reputation: 233150
F# Interactive is a Read-Eval-Print-Loop (REPL), which is an ad-hoc environment that enables you to experiment with F# code. Many Functional programming languages come with a REPL.
You can highlight a piece of F# code in the normal editor and send it to F# Interactive with Alt+Enter. You can also write code directly in the F# Interactive. In order to focus in the window, you can use Ctrl+Alt+F.
F# Interactive is also available as the command-line program fsi.exe, independent of Visual Studio. This makes F# accessible to people without access to Visual Studio.
There are various other ways to experiment with code and APIs. My personal preference is to use Test-Driven Development (TDD), which is one alternative to using a REPL. With TDD, I leave behind a suite of tests, which can often be beneficial. However, unit testing is a somewhat 'heavier' process, because I have to pull in a unit testing framework, and write assertions. Sometimes, I just need to experiment with various syntax alternatives or ways to model a concept, and the REPL provides more lightweight alternative to that. However, when I use F# Interactive, no test artefacts are left behind.
Upvotes: 13