2

I just ran into a Haskell module that appears not to export anything. Schwifty/Swift/M105/Types.hs:

module Schwifty.Swift.M105.Types where

There are other modules in the project that import it.

import Schwifty.Swift.M105.Types

I thought Haskell modules always had to declare their exports. What does it mean when you don't?

0

2 Answers 2

7

You have to distinguish

  1. an empty export list (module Foo () where) and
  2. no export list at all (module Foo where).

The empty export list means: Export no value or type definitions. However, the module still exports all instance declarations from the module itself, and from all imported modules, so modules with empty export lists can be useful.

No export list at all means: Export all value and type definitions made in the module itself. (And all instance declarations, too, of course).

6

From A Gentle Introduction to Haskell, Version 98:

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.