本文介绍了Haskell QuickCheck2使用ByteString?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 实例Arbitrary B.ByteString其中
任意= fmap B.pack任意
coarbitrary =任意。 B.unpack

但是我的GHC 7.2与QuickCheck 2.4.1.1告诉我:

 `coarbitrary'不是'Arbitrary'类的(可见)方法

任何指针?

解决方案

coarbitrary 已经转移到QC 2.0中它自己的类型类型 CoAbritary 中,所以只需删除 coarbitrary 的等式。

另见。


The RWH books says that to get ByteString support, I need to add:

instance Arbitrary B.ByteString where
    arbitrary   = fmap B.pack arbitrary
    coarbitrary = coarbitrary . B.unpack

But my GHC 7.2 with QuickCheck 2.4.1.1 tells me:

`coarbitrary' is not a (visible) method of class `Arbitrary'

Any pointers?

解决方案

coarbitrary has moved to it's own typeclass CoAbritary in QC 2.0, so simply just remove the equation for coarbitrary.

Also see the latest documentation.

这篇关于Haskell QuickCheck2使用ByteString?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 02:31