Haddock: Documentation for instance functions with quirks replaced by default

Consider the following example:

instance (Monad m) => MonadState s (ChronoT sem) where -- | Returns the present-day state. get = ChronoT $ do (ChronoS _ s _) <- get return s -- | Set the present-day state directly, erasing the past and future for -- safety. See also 'paradox'. put x = ChronoT $ do (ChronoS _ _ _) <- get put $ mkChronoS x 

When launched through the peak, the get and put functions are displayed, but they use the default documentation from MonadState. How to include my own documentation in my module?

(You can see what I mean by running cabal haddock on top of the repo here )

+6
source share
1 answer

You can not.

What you can do is document your instance.

 -- | You can have a brief description here instance (Monad m) => MonadState s (ChronoT sem) where … 

This will cause the description to be displayed on the side of the instances field. This should be brief, but it allows you to do things such as, for example, telling the user documentation about functions that implement fields, if you really need it, for example, commenting on a question.

Personally, I believe that it makes no sense to document each field as follows: what the fields should do should be clear from the documentation for the class definition and the comment for the instance.

+3
source

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


All Articles