请考虑以下示例:
instance (Monad m) => MonadState s (ChronoT s e m) 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
Run Code Online (Sandbox Code Playgroud)
当通过黑线鳕运行,功能get和put显示出来,但他们使用的是从MonadState默认文档.如何在我的模块中包含我自己的文档?
(你可以cabal haddock在这里看看我的意思,看看我的意思)
你不能。
\n\n您可以做的就是记录您的实例。
\n\n-- | You can have a brief description here\ninstance (Monad m) => MonadState s (ChronoT s e m) where\n\xe2\x80\xa6\nRun Code Online (Sandbox Code Playgroud)\n\n这将使描述显示在instances生成的框的一侧。这最好应该简短,但它确实可以让您做一些事情,例如如果您确实需要的话,可以向用户指出实现字段的函数的文档,就像问题的评论者所建议的那样。
就我个人而言,我认为像这样记录每个字段没有多大意义:从类定义的文档和实例的注释中应该清楚这些字段的用途。
\n