Split F# modules across multiple files

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.

Leave a Comment