Change documentation for re-exported types and values

Suppose I have a module that re-exports a value from an internal module:

module My.Cool.Module (SomeType, someValue) where
import My.Cool.Module.Internal (SomeType, someValue)

I would like to show various documentation for SomeTypeboth someValuein My-Cool-Module.htmland My-Cool-Module-Internal.html, so the former can discuss the public API, and the latter can discuss how they relate to the rest of the internal elements.

Is there any way to do this with haddock?

I tried:

module My.Cool.Module (SomeType, someValue) where
import My.Cool.Module.Internal
  ( SomeType -- ^ a serious type for serious people
  , someValue -- ^ a serious value for serious people
  )

But haddock gave me a parse error:

parse error on input β€˜-- ^ a serious type for serious people’
+4
source share
1 answer

Well, here's a hack I can live with.

Haddock , , . , , , .

, , , API:

-- | Have you welcomed internal modules into your life?
module Public.Private where

-- | Here the public API information for 'SomeType'
type SomeType = ()
-- $
-- Here the internal information about 'SomeType': it really just a stand-in
-- for San Francisco

-- | Here the public API information for 'someValue'
someValue :: SomeType
-- $ Here the internal information about 'someValue': it loves cheese.
someValue = ()

-- | This is a very serious public API
module Public ( SomeType, someValue) where
import Public.Private ( SomeType , someValue)

Public.Private :

Generated HTML documentation for Public.Private

Public :

Shared HTML documentation

, , .

+3

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


All Articles