Haskell Language Modules Hierarchical module names


The names of modules follow the filesystem's hierarchical structure. With the following file layout:

├── Baz/
│   └── Quux.hs
└── Bar.hs

the module headers would look like this:

-- file Foo.hs
module Foo where

-- file Bar.hs
module Bar where

-- file Foo/Bar.hs
module Foo.Bar where

-- file Foo/Baz/Quux.hs
module Foo.Baz.Quux where

Note that:

  • the module name is based on the path of the file declaring the module
  • Folders may share a name with a module, which gives a naturally hierarchical naming structure to modules