gpt4 book ai didi

f# - 在 FSI 中加载 F# 模块

转载 作者:行者123 更新时间:2023-12-04 21:40:41 28 4
gpt4 key购买 nike

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

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

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



我还注意到 InteractiveUtil 模块的定义如下所示:
namespace FSI_0009
module InteractiveUtil = begin
val plotMe : c:FSharp.Charting.ChartTypes.GenericChart -> unit
val logMe : c:string -> unit
end

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

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

最佳答案

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

module InteractiveUtil

#time
#r ...
open FSharp.Charting

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

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

关于f# - 在 FSI 中加载 F# 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27409266/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com