这是我的代码的抽象:
module RootModule
module private SubModule = // I want everything in this module to be inaccessible from outside the file
let getLength s = String.Length s
type MyType (s: string) =
let _str = s
member this.GetStringLength = getLength _str // for sake of simplicity, a bogus method
let myExternalValue = new SubModule.MyType("Hello")
我得到错误Type 'MyType' is less accessible than the value, member, or type: 'val myExternalValue: SubModule.MyType' it is used in
为什么我不能像这样拥有对私有类实例的公共访问器?请注意,我RootModule
在一个不同的文件中一起使用,并且只希望myExternalValue
在另一个文件中可见