简体   繁体   English

Visual Studio 2017问题与F#中的名称空间

[英]Visual studio 2017 problem with namespaces in F#

I wrote this in HelperFunctions.fs: 我在HelperFunctions.fs中编写了此代码:

namespace Tutorial1.HelperFunctions

module Factorials = 

    let rec fact n = 
        match n with
            | 0 -> 1
            | 1 -> 1
            | _ -> n * fact (n - 1)

And then this in Tutorial.fsx: 然后在Tutorial.fsx中:

#load "HelperFunctions.fs"
open Tutorial1.HelperFunctions

module start = 
    let x = Factorials.fact 5
    printfn "%d" x

Code compiles and returns 120 as expected BUT: VS throws FS0039 error: Factorials and Tutorial1 namespace, type or module not defined... Tried many other combinations of open, module etc but then codes does not even compile. 代码将按预期方式编译并返回120,但是:VS抛出FS0039错误:因子和Tutorial1命名空间,类型或模块未定义...尝试了open,module等的许多其他组合,但代码甚至没有编译。 What is the problem I am not seeing here? 我在这里没看到什么问题?

Okay, apparently the order of files in the vstudio matters, even if you include the file with #load. 好吧,即使您在文件中包含#load,显然vstudio中文件的顺序也很重要。 I had to shift the files upwards and it worked 我不得不将文件向上移动,但它确实有效

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM