3

I notice that each time I open F# Interactive (FSI) from within Visual Studio to tryout something REPL-style, I always find myself executing a few commands first, often specific for any given project:

open System;;
#r @"r:\projects\currentprjLibs.dll";;
#r @"r:\external\unquote.dll";;
#time;;

This is just an example, but I find myself asking: can this be automated? Now, I could have an fsx script for each project and do a "send to interactive", but this is still quite a bit of work (and #r or #time won't work there). Besides, I have to do it again on each FSI Reset.

Does anybody know of a simpler way? Should I roll my own (I never created a serious add-in for Visual Studio, but maybe now is a good time). Other suggestions?


PS: the solution here is not what I am after, as it applies to every instance of FSI and it doesn't do opens. The 2nd solution there is to add #if INTERACTIVE, but this adds clutter, is difficult to write with relative paths, and Ctrl-A plus Ctrl+Shift+Enter will choke on any namespace, which then also needs to be in #if !INTERACTIVE, adding more clutter.

Community
  • 1
  • 1
Abel
  • 56,041
  • 24
  • 146
  • 247
  • 1
    I remember a long time ago that we had a similar need on a project and the ideal solution was to have a dependency tree, and then you use only one reference and the rest get brought in because of the dependencies. It was an F# suggestion but I don't know if it was ever implemented. The idea came about when translating OCaml to F#. See: [Dependency generator (ocamldep)](http://caml.inria.fr/pub/docs/manual-ocaml/depend.html) – Guy Coder Dec 21 '16 at 19:54
  • IIRC you seek [OCaml #use](https://caml.inria.fr/pub/docs/manual-ocaml/toplevel.html#sec275) but for F#. – Guy Coder Dec 21 '16 at 20:01
  • Found the F# User Voice request. It was declined. [Fix the #use directive in F# interactive](https://fslang.uservoice.com/forums/245727-f-language/suggestions/5670098-fix-the-use-directive-in-f-interactive) If that is acceptable as an answer, let me know. – Guy Coder Dec 21 '16 at 20:04
  • What we finally did for the project was to just open everything and do it with one fsx file. [init_all.fsx](https://github.com/jack-pappas/fsharp-logic-examples/blob/master/Examples/init_all.fsx) – Guy Coder Dec 21 '16 at 20:16
  • @guy, your last comment is something we used to do as well, but it is suboptimal at best and still requires quite a few steps on each session, which defies the idea or usefulness of REPL, I think. – Abel Dec 21 '16 at 20:20
  • I should have noted that `init_all.fsx` is not a suggestion or answer, but what we finally did. We were not pleased either. – Guy Coder Dec 21 '16 at 20:24

0 Answers0