在FSI中加载F#模块

时间:2014-12-10 19:28:51

标签: f#

我有一个fsx文件,我用它来进行项目的交互式开发。它预加载了所有的dll,我想模拟一些在FSI世界中应该表现不同的函数。

在fsx中我有这段代码:

// #r needed dlls
open FSharp.Charting

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

现在我想玩的.fs文件中有这个:

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

但是当我尝试执行上面的代码段时,我得到了

  

错误FS0039:命名空间或模块' InteractiveUtil'未定义

我还注意到InteractiveUtil模块的定义如下:

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

所以FSI_0009是fsi为我创造的东西。

知道怎么解决这个问题吗?

1 个答案:

答案 0 :(得分:1)

好的,明白了。当我把顶级模块放在fsx的开头时,它起作用了。

module InteractiveUtil

#time
#r ...
open FSharp.Charting

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

我会删除这个问题,但由于我已经投了一票,似乎其他人对解决方案感兴趣。

相关问题