首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >记录字段中的Haddock Haskell

记录字段中的Haddock Haskell
EN

Stack Overflow用户
提问于 2013-02-17 03:19:15
回答 1查看 342关注 0票数 1

我正在尝试为接口上的记录字段写入haddock。只有一些字段被导出,所以我只想要它们中的一些文档。我在这里阅读了文档页面:http://www.haskell.org/haddock/doc/html/ch03s02.html#id565178

然而,我似乎不能让它工作。这是我尝试为其编写haddock的部分:

代码语言:javascript
复制
{-|
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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-02-17 06:25:44

不幸的是,haddock目前还不支持将一个记录的少数字段的文档显示为该记录的字段。您可以通过导出所有字段来解决此问题:

代码语言:javascript
复制
module Foo (ClientConn(..)) where ...

或通过导出字段,但不是作为字段导出:

代码语言:javascript
复制
module Foo (ClientConn, cid, lookup, modify) where ...

在后一种情况下,文档不会自动指出这些函数实际上是字段,但它们在记录语法中是可用的。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14914138

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档