2

インターフェイスのレコード フィールドにハドックを書き込もうとしています。一部のフィールドのみがエクスポートされるため、それらの一部のみを文書化します。ここでドキュメントページを読みました: 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、lookup、およびmodifyレコードを生成したいと思います。

前もって感謝します!

完全なソースはここにあります: https://github.com/jcollard/simple-server/blob/master/Network/SimpleServer.hs

4

1 に答える 1

3

残念ながら、haddockは現在、レコードのフィールドの一部のみをそのレコードのフィールドとして表示することをサポートしていません。すべてのフィールドをエクスポートすることで、これを回避できます。

module Foo (ClientConn(..)) where ...

または、フィールドをエクスポートしますが、フィールドとしてはエクスポートしません。

module Foo (ClientConn, cid, lookup, modify) where ...

後者の場合、ドキュメントはこれらの関数が実際にフィールドであることを自動的に示しませんが、レコード構文で使用できます。

于 2013-02-16T22:25:44.240 に答える