August Feng

Fsharp namespaces and modules

About

This article documents some understandings on namespace and modules in F# projects.

Namespace

F# namespaces must be declared at the top of the file. They cannot hold values.

Strictly speaking, they're not required and do not appear in the full name of the member items if they're absent.

Module

F# modules translate to static CLR classes. There are two types of modules: top-level and local.

The top-level modules do not end with a = and are necessary if a namespace is not specified. If the module identifier contains a dot, then everything before the last dot is considered as a namespace.

Diagram

stateDiagram-v2 [*] --> file [*] --> files file --> namespace files --> namespace file --> top_level_module file --> local_module files --> top_level_module namespace --> local_module local_module --> [*] top_level_module --> local_module top_level_module --> [*]