我正在尝试为界面上的记录字段编写 haddock 。仅导出部分字段,因此我只希望记录其中的一些字段。我在这里阅读了文档页面:http://www.haskell.org/haddock/doc/html/ch03s02.html#id565178
但是,我似乎无法让它发挥作用。这是我试图为其编写黑线鳕的部分:
{-|
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
最佳答案
不幸的是,haddock 目前不支持仅将记录的几个字段的文档显示为该记录的字段。您可以通过导出所有字段来解决此问题:
module Foo (ClientConn(..)) where ...
或者通过导出字段,但不是作为字段:
module Foo (ClientConn, cid, lookup, modify) where ...
在后一种情况下,文档不会自动指示这些函数实际上是字段,但它们可以在记录语法中使用。
关于haskell - Haskell 记录场上的黑线鳕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14914138/