Haddock Haddock and without warning of excess import

There is a dummy module in my project whose sole purpose is to store the Haddock documentation for the rest of the library. In fact, I do not need to import anything in this module, but if I do not import other modules, Haddock does not associate function names with their modules.

My module is as follows

{- | Lots of Haddock text here... it references 'someFunction'. -} module TopLevelDoc () where import Other.Module.With.SomeFunction 

Now, if I create a project, I get this warning:

  Warning: The import of `Other.Module.With.SomeFunction' is redundant except perhaps to import instances from `Other.Module.With.SomeFunction' To import instances alone, use: import Other.Module.With.SomeFunction() 

If I delete the import or make them () , Haddock will not add someFunction hyperlink to its documentation. If I leave the import as it is, I get a lot of false warnings that I don't like. And I do not want to suppress this warning for the whole project, it can be useful for any other module except this.

Questions:

  • How to get a hyperlink to Haddock output without such warnings when creating?
  • Can I turn off warnings for each file? (for example, I can do it globally with ghc-options in .cabal )
+4
source share
1 answer

To disable the warning about unused import, you can put the pragma at the beginning of the file:

 {-# OPTIONS_GHC -fno-warn-unused-imports #-} 

You can refer to identifiers that are not in scope by explicitly defining them:

You can also refer to objects that are not in scope in the current module by providing the fully qualified name of the object:

 -- | The identifier 'MT' is not in scope 

If MT has no other value in scope, then Haddock simply provides a link pointing to an object T exported from module M (without checking if M or MT exists).

- Haddock User Guide

However, this is likely to make your documentation source pretty ugly, and the module’s qualifications will not be removed from the output, so I recommend disabling warnings.

+6
source

Source: https://habr.com/ru/post/1394393/


All Articles