【问题标题】:Loading F# module in FSI在 FSI 中加载 F# 模块
【发布时间】:2015-02-09 03:14:24
【问题描述】:

我有一个 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

但是当我尝试执行上面的 sn-p 时,我得到了

错误 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 为我创建的。

知道如何解决这个问题吗?

【问题讨论】:

    标签: f#


    【解决方案1】:

    好的,知道了。当我将顶级模块放在 fsx 的开头时,它起作用了。

    module InteractiveUtil
    
    #time
    #r ...
    open FSharp.Charting
    
    let plotMe (c : ChartTypes.GenericChart) = c.ShowChart() |> ignore
    let logMe (c : string) = c |> printfn "%s"
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-06
      • 2016-06-12
      • 1970-01-01
      • 1970-01-01
      • 2011-03-06
      • 2014-08-07
      相关资源
      最近更新 更多