Loading an F # Module in FSI

I have an fsx file that I am using to interactively develop my project. It preloads all DLLs, plus I want to mock a few functions that should behave differently in the FSI world.

In fsx, I have this code:

// #r needed dlls
open FSharp.Charting

module InteractiveUtil =
    let plotMe (c : ChartTypes.GenericChart) = c.ShowChart() |> ignore
    let logMe (c : string) = c |> printfn "%s"

      

Now in .fs files, I want to play with this:

#if INTERACTIVE
#load "LiveInvestigationPreload.fsx"
open InteractiveUtil
#endif

      

But when I try to execute the snippet above I get

error FS0039: namespace or module 'InteractiveUtil' is not defined

I also noticed that the definition of the InteractiveUtil module looks like this:

namespace FSI_0009
  module InteractiveUtil = begin
    val plotMe : c:FSharp.Charting.ChartTypes.GenericChart -> unit
    val logMe : c:string -> unit
  end

      

So FSI_0009 is something fsi built for me.

Any idea how to get around this?

+3


source to share


1 answer


Okay, got it. When I put the top level module at the beginning of the fsx it worked.

module InteractiveUtil

#time
#r ...
open FSharp.Charting

let plotMe (c : ChartTypes.GenericChart) = c.ShowChart() |> ignore
let logMe (c : string) = c |> printfn "%s"

      



I would delete the question, but since I got one vote already, it seems like someone is interested in a solution.

+1


source







All Articles