Haskell LanguageModules


Syntax

  • module Name where -- export all names declared in this file

  • module Name (functionOne, Type (..)) where -- export only functionOne, Type, and Type's constructors

  • import Module -- import all of Module's exported names

  • import qualified Module as MN -- qualified import

  • import Module (justThisFunction) -- import only certain names from a module

  • import Module hiding (functionName, Type) -- import all names from a module except functionName and Type

Remarks

Haskell has support for modules:

  • a module can export all, or a subset of its member types & functions

  • a module can "re-export" names it imported from other modules

On the consumer end of a module, one can:

  • import all, or a subset of module members

  • hide imports of a particular member or set of members

haskell.org has a great chapter on module definition.