我正在尝试在接口上为记录字段写入haddock。只导出了一些字段,因此我只想记录其中的一些字段。我在这里阅读了文档页面:http://www.haskell.org/haddock/doc/html/ch03s02.html#id565178
然而,我似乎无法让这个工作。以下是我试图编写haddock的部分:
{-|
Describes a Clients connection and provides an interface for
storing data associated with the client. Each client will be given
a unique cid and are Eq if their cid's are Eq.
A ClientConn comes packaged with two functions for storing additional
information in Strings, lookup and modify. The lookup function
takes a key and returns the current value of the key or the empty
string if it has never been set. The modify function
takes a key and value and updates it such that the next call to
lookup with that key will return the value provided.
-}
data ClientConn = ClientConn { -- | The Unique ID for this client
cid :: Integer,
-- | A lookup function for this client
lookup :: (String -> IO String),
-- | A modify function for this client
modify :: (String -> String -> IO ()),
chandle :: Handle,
host :: Net.HostName,
pid :: Net.PortNumber,
msgList :: List String,
dead :: MVar Bool,
timestamp :: TimeStamp,
tid :: MVar (ThreadId, ThreadId),
lock :: MVar Lock.Lock}
数据类型的注释在生成的haddock中正确显示。但是,没有生成任何记录。我希望它为cid生成,查找和修改记录。
提前致谢!
可以在此处找到完整的来源:https://github.com/jcollard/simple-server/blob/master/Network/SimpleServer.hs
答案 0 :(得分:3)
不幸的是,haddock目前不支持只显示记录字段中的少数文档作为该记录的字段。您可以通过导出所有字段来解决此问题:
module Foo (ClientConn(..)) where ...
或导出字段,但不是字段:
module Foo (ClientConn, cid, lookup, modify) where ...
在后一种情况下,文档不会自动指示这些函数实际上是字段,但它们可用于记录语法。