Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any tool for aiding with explicit import of modules in Haskell?

After considering the reasons here to always import modules explicitly (with the exception of Prelude), I am trying to abide by this norm. However, this may sometimes be cumbersome. Is there any tool which would analyze working code and give a complete list of explicit imports?

like image 616
Pablo Avatar asked Nov 04 '14 19:11

Pablo


People also ask

How do I import modules in Haskell?

The syntax for importing modules in a Haskell script is import <module name>. This must be done before defining any functions, so imports are usually done at the top of the file. One script can, of course, import several modules. Just put each import statement into a separate line.

What is a qualified import?

A qualified import allows using functions with the same name imported from several modules, e.g. map from the Prelude and map from Data.

What is Prelude in Ghci?

Prelude is a module that contains a small set of standard definitions and is included automatically into all Haskell modules.

What does module where do in Haskell?

A module in Haskell serves the dual purpose of controlling name-spaces and creating abstract data types.

What is a module in Haskell?

A module in Haskell serves the dual purpose of controlling name-spaces and creating abstract data types. The top level of a module contains any of the various declarations we have discussed: fixity declarations, data and type declarations, class and instance declarations, type signatures, function definitions, and pattern bindings.

What is a Haskell program?

A Haskell program consists of a collection of modules. A module in Haskell serves the dual purpose of controlling name-spaces and creating abstract data types.

What are the rules for import and export in Haskell?

Although Haskell's module system is relatively conservative, there are many rules concerning the import and export of values. Most of these are obvious---for instance, it is illegal to import two different entities having the same name into the same scope.

What are qualified names in Haskell?

Haskell solves this problem using qualified names. An import declaration may use the qualified keyword to cause the imported names to be prefixed by the name of the module imported. These prefixes are followed by the `.' character without intervening whitespace. [Qualifiers are part of the lexical syntax.


1 Answers

There is the -ddump-minimal-imports flag for ghc.

The results are placed in the file (module-name).imports.

The -fno-code ghc option is also helpful here (to avoid the code generation phase.)

like image 82
ErikR Avatar answered Oct 15 '22 02:10

ErikR