以下交互显示如何使用可用于Haskell的Math.Combinatorics.Species库的最新版本(版本0.4)来枚举集合的子集。我想弄清楚如何使用相同的库来枚举集合的分区,但我无法理解并修复我得到的类型错误。更具体地说,我不了解分区的structureType,":Set Set"意思?
<domain type='qemu'>
<name>Linux ARM</name>
<uuid>ce1326f0-a9a0-11e3-a5e2-0800200c9a66</uuid>
<memory>131072</memory>
<currentMemory>131072</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch="armv7l" machine='versatilepb'>hvm</type>
<kernel>/path/to/zImage</kernel>
<cmdline>root=/dev/sda console=ttyAMA0,115200</cmdline>
<dtb>/path/to/versatile-pb.dtb</dtb>
</os>
<devices>
<disk type="file" device="disk">
<driver name="qemu" type="qcow2"></driver>
<source file="/path/to/root.qcow2"></source>
<target dev="sda" bus="sd"></target>
</disk>
<serial type="tcp">
<source mode="bind" host="localhost" service="4000"></source>
<protocol type="telnet"></protocol>
</serial>
</devices>
</domain>
答案 0 :(得分:1)
似乎这是structureType
使用的漂亮打印机中的一个错误。我已经报告了问题here;与此同时,只要您将:.:
视为类型构造函数,就应该使用:
。所以,像这样:
S I> S.enumerate S.partition [1,2,3] :: [(S.Set S.:.: S.Set) I.Int]
[{{1,2,3}},{{2,3},{1}},{{2},{1,3}},{{3},{1,2}},{{3},{2},{1}}]