A namespace logically groups types. It gives related types a shared qualified path, making large codebases easier to navigate and helping distinguish similarly named types. In F#, core .NET types such as DateTime, String, and Int32 are available through System. section 2.4.3 section 6.2
Namespaces form a hierarchy. For example, File belongs to System.IO and ZipFile to System.IO.Compression. A namespace declaration applies to following type declarations until another namespace declaration appears. Types can be referenced with their full path, such as Foo.Order. section 6.2.1
Qualify first, then open
Use a full name when clarity matters or when introducing a dependency: namespace Bar.Baz open Foo type Customer = { LastOrder : Order } Opening Foo lets Order be used directly instead of Foo.Order. This removes repeated qualification, but namespaces still contain types rather than values. Use a module when a group needs functions or values. section 6.2.1 section 6.4
Listing 6.6 Working with namespaces in F#
namespace Foo #1
type Order = { Name : string } #2
namespace Bar.Baz #3
type Customer = #4
{
Name : string
LastOrder : Foo.Order #5
}
Compare a root namespace, a nested namespace, and a fully qualified type reference in one small declaration sequence. section 6.2.1
Use namespaces deliberately as an application grows:
- Start small applications with modules when code needs both types and functions; modules can also be opened and nested. section 6.2.5
- Introduce namespaces when modules in different files need a shared parent, such as Contoso.WebApi.Orders and Contoso.WebApi.Customers. section 6.2.5
- Share a namespace across multiple application files, packages, or third-party code when the type hierarchy warrants it. section 6.2.1
- Open System at the top of a program to use Console directly rather than repeatedly typing System.Console. section 6.2.3
Namespaces are ordinary .NET namespaces when F# code is consumed from C#, so their names and behavior remain familiar across the two languages. That interoperability makes namespaces useful at library and application boundaries, not only inside F# code. section 11.2.1



















