Haskell 如何为hsc2hs枚举成员制作haddock文档

Haskell 如何为hsc2hs枚举成员制作haddock文档,haskell,haddock,hsc2hs,Haskell,Haddock,Hsc2hs,我正在使用hsc2hs从C头导入一组枚举值。我的代码(简化)如下所示: -- | newtype wrapper around Windows SDK SE_OBJECT_TYPE enumeration newtype SecurityObjectType = SecurityObjectType BYTE #{enum SecurityObjectType, SecurityObjectType , securityObjectUnknown = SE_UNKNOWN

我正在使用hsc2hs从C头导入一组枚举值。我的代码(简化)如下所示:

-- | newtype wrapper around Windows SDK SE_OBJECT_TYPE enumeration
newtype SecurityObjectType = SecurityObjectType BYTE
#{enum SecurityObjectType, SecurityObjectType
 , securityObjectUnknown            = SE_UNKNOWN_OBJECT_TYPE
 , securityObjectFile               = SE_FILE_OBJECT
 }
当我在我的项目上运行
cabal haddock
时,它会为
SecurityObjectType
类型的声明
securityObjectUnknown
securityObjectFile
创建空文档块。现在,我想要这些文档。只需使用haddock风格的注释,如

-- | newtype wrapper around Windows SDK SE_OBJECT_TYPE enumeration
newtype SecurityObjectType = SecurityObjectType BYTE
#{enum SecurityObjectType, SecurityObjectType
 -- | Unknown object type
 , securityObjectUnknown            = SE_UNKNOWN_OBJECT_TYPE
 -- | Indicates a file or directory. The name string that identifies a file
 -- or directory object can be in one of the following formats:
 --  * A relative path, such as FileName.dat or ..\FileName
 --  * An absolute path, such as FileName.dat, C:\DirectoryName\FileName.dat,
 --    or G:\RemoteDirectoryName\FileName.dat.
 --  * A UNC name, such as \\ComputerName\ShareName\FileName.dat.
 , securityObjectFile               = SE_FILE_OBJECT
 }
干扰hsc2hs并导致生成失败。但我想把这些声明记录下来。我怎么能这么做

UPD:如果我有评论,下面是生成过程中生成的错误消息:

Preprocessing library Win32-security-0.1...                                                                                     
SecurityInfo.hsc: In function 'main':                                                                                           
SecurityInfo.hsc:47:5: error: lvalue required as decrement operand                                                              
SecurityInfo.hsc:47:5: error: 'Indicates' undeclared (first use in this function)                                               
SecurityInfo.hsc:47:5: note: each undeclared identifier is reported only once for each function it appears in                   
SecurityInfo.hsc:47:5: error: expected ')' before 'a'                                                                           
SecurityInfo.hsc:47:5: error: lvalue required as decrement operand                                                              
SecurityInfo.hsc:47:5: error: expected ')' before 'a'                                                                           
SecurityInfo.hsc:47:5: error: lvalue required as decrement operand                                                              
SecurityInfo.hsc:47:5: error: expected ')' before 'a'                                                                           
SecurityInfo.hsc:55:20: warning: missing terminating " character                                                                
SecurityInfo.hsc:56:24: warning: missing terminating " character                                                                
SecurityInfo.hsc:66:20: warning: missing terminating " character                                                                
SecurityInfo.hsc:67:18: warning: missing terminating " character                                                                
SecurityInfo.hsc:71:20: warning: missing terminating " character                                                                
SecurityInfo.hsc:72:2: warning: missing terminating " character                                                                 
SecurityInfo.hsc:237:0: error: unterminated argument list invoking macro "hsc_enum"                                             
SecurityInfo.hsc:53:5: error: 'hsc_enum' undeclared (first use in this function)                                                
SecurityInfo.hsc:53:5: error: expected ';' at end of input                                                                      
SecurityInfo.hsc:53:5: error: expected declaration or statement at end of input                                                 
compiling dist\build\System\Win32\Security\SecurityInfo_hsc_make.c failed (exit code 1)                 
由于简化了示例,行号实际上并不匹配,但错误输出中的第47行对应于一个
——|未知对象类型

深入挖掘生成的
SecurityInfo\u hsc\u make.c
文件清楚地显示了一个问题(这里是一个片段):


Haskell注释只是插入到生成的C文件中,这显然违反了C语法规则。我想要的是将这些注释传播到自动生成的
.hs
文件中

据我所知,如果要添加文档,您必须使用
#const
一次定义一个值,而不是使用
#enum
一次定义所有值

-- | Unknown object type
securityObjectUnknown :: SecurityObjectType
securityObjectUnknown = SecurityObjectType #const SE_UNKNOWN_OBJECT_TYPE

-- | Indicates a file or directory. The name string that identifies a file
-- or directory object can be in one of the following formats:
--  * A relative path, such as FileName.dat or ..\FileName
--  * An absolute path, such as FileName.dat, C:\DirectoryName\FileName.dat,
--    or G:\RemoteDirectoryName\FileName.dat.
--  * A UNC name, such as \\ComputerName\ShareName\FileName.dat.
securityObjectFile :: SecurityObjectType
securityObjectFile = SecurityObjectType #const SE_FILE_OBJECT

请详细说明如何添加评论干扰hsc2hs
-- | Unknown object type
securityObjectUnknown :: SecurityObjectType
securityObjectUnknown = SecurityObjectType #const SE_UNKNOWN_OBJECT_TYPE

-- | Indicates a file or directory. The name string that identifies a file
-- or directory object can be in one of the following formats:
--  * A relative path, such as FileName.dat or ..\FileName
--  * An absolute path, such as FileName.dat, C:\DirectoryName\FileName.dat,
--    or G:\RemoteDirectoryName\FileName.dat.
--  * A UNC name, such as \\ComputerName\ShareName\FileName.dat.
securityObjectFile :: SecurityObjectType
securityObjectFile = SecurityObjectType #const SE_FILE_OBJECT