Haskell Language Modules Exporting Constructors

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

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.



Got any Haskell Language Question?