Reputation: 727
I'm learning F# recently and using it to solve problems like "Haskell 99 problems" as a practice. I'm coding with Visual Studio 2013 Community on Windows.
My problem is that I don't know how to organize all my sources codes in one solution/project.
In other languages like Ruby, I could organize my source codes like:
haskell99/
problem1.rb
problem2.rb
...
problem99.rb
I could code and execute each source file independently in any IDE.
But if I organize my F# source codes in a similar way in Visual Studio:
Solution 'Haskell99'
Project 'Haskell99'
problem1.fs
problem2.fs
...
problem99.fs
I can not just switch to a source code and press Ctrl+F5 to execute it. If I do so, all the source codes contained in this Solution will be compiled to one single .exe file.
I also tried other ways like one project per problem:
Solution 'Haskell99'
Project 'Problem1'
Program.fs
Project 'Problem2'
Program.fs
...
Project 'Problem99'
Program.fs
Or F# scripts in a solution:
Solution 'Haskell99'
Project 'Haskell99'
problem1.fsx
problem2.fsx
...
problem99.fsx
They all not work.
Is there any best practice to achieve this:
Switch to a source file by double click it;
Then press Ctrl + F5 to ONLY compile and execute this source file.
Thanks for your response in advance.
Upvotes: 1
Views: 295
Reputation: 10781
If you need to start a debugger, then your one-project-per-problem is the only option. It's one extra step, but if you follow http://blog.michaelckennedy.net/2007/07/30/visual-studio-tricks-series-1-set-as-startup-project/ to add a hotkey to set-as-startup-project, then your process is
Or if you don't need the file open in the editor, it's just
Upvotes: 2
Reputation: 10781
Install F# power tools, and when you have an .fsx file open in your editor, there's an option to "Execute in Interactive". You can map this to any key combo you want.
Upvotes: 3