Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When specifying an empty export list can be useful?

Tags:

module

haskell

It is possible to export no names of a module by specifying just a pair of parenthesis as the export list:

module MyModule () where

In which scenarios would this be useful? As far as I understand, any file importing MyModule won't be able to use any functions or types declared inside MyModule. At this point is seems like a useless feature of the langauge, but I suppose it is there for a reason.

like image 669
Kapol Avatar asked Aug 01 '15 13:08

Kapol


1 Answers

Such a module will still export any class instances defined therein.

module A where

class Foo f where
  foo :: f

data Bar = Bar deriving (Show)

module B () where

import A

instance Foo Bar where
  foo = Bar

module C where

import A
import B -- won't compile without this import!

main = print (foo :: Bar)
like image 118
leftaroundabout Avatar answered Nov 02 '22 09:11

leftaroundabout