Explain an empty Haskell () import list

I saw a lot of lines like import HSP.ServerPartT() - the import list is empty. Why is this done? What is the only difference with importing this module?

+7
source share
2 answers

It imports only typeclass instances from the module. Using -Wall GHC issues a warning for imported modules, but from which definitions are not used:

 foo.hs:1:1: Warning: The import of `M' is redundant except perhaps to import instances from `M' To import instances alone, use: import M() 

An empty import list blocks this warning and serves as documentation of the purpose of the import.

+15
source

This form imports nothing but instances from this module. And what is the reason for this form, you want to have instances in scope, but nothing else.

+3
source

All Articles