Haskell Language Exporting Constructors


Example

To export the type and all its constructors, one must use the following syntax:

module X (Person (..)) where

So, for the following top-level definitions in a file called People.hs:

data Person = Friend String | Foe deriving (Show, Eq, Ord)

isFoe Foe = True
isFoe _   = False

This module declaration at the top:

module People (Person (..)) where

would only export Person and its constructors Friend and Foe.

If the export list following the module keyword is omitted, all of the names bound at the top level of the module would be exported:

module People where

would export Person, its constructors, and the isFoe function.