Split F# modules across multiple files

前端 未结 5 1861
攒了一身酷
攒了一身酷 2021-01-01 08:51

Is it possible to split an F# module across files?

According to the book I have it is, but the book is probably outdated (Foundations of F#)

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-01 09:37

    Apparently not:

    C:\temp\Tim>type 1.fs 2.fs
    
    1.fs
    
    
    #light
    module Module
    
    let sayHello1 = printfn "Hello, "
    
    2.fs
    
    
    #light
    module Module
    
    let sayHello2 = printfn "world!"
    
    C:\temp\Tim>fsc 1.fs 2.fs
    Microsoft F# Compiler, (c) Microsoft Corporation, All Rights Reserved
    F# Version 1.9.6.2, compiling for .NET Framework Version v2.0.50727
    
    2.fs(2,1): error FS0191: An implementation of the file or module Module has already been given.
    

    Update: the error has changed in F# 4.0, it is now:

    error FS0248: Two modules named 'Module' occur in two parts of this assembly

    where Module is the fully qualified name of your assembly, including the namespace part.

提交回复
热议问题