什么是用于与类似于快速检查的promote功能,即,形式的功能的结构的函子的总称: promote :: (a -> f b) -> f (a -> b)
(这是flip $ fmap (flip ($)) :: f (a -> b) -> (a -> f b)倒数)。除了(->) r和Id以外,是否还有任何具有此类操作的仿函数? (我确定必须有)。谷歌搜索'快速检查推广'只是出现了Quick
我有以下, type Pos = (Int, Int)
我要生成这种类型的随机值有一些限制(这两个必须是0-8) 我会的任意intance喜欢做类似 instance Arbitrary Pos where
arbitrary = do x <- choose(0,8)
y <- choose(0,8)
return (x,y)
然后在我的测试中使
我试图使用HSpec和QuickCheck来验证属性的猿(关联性和标识元素)。我要验证特定的实例,但想保留大部分代码多态。这是我想出了几个小时后: module Test where
import Test.Hspec
import Test.QuickCheck
import Data.Monoid
instance (Arbitrary a) => Arbitrary (Sum a
我有一个环型类看起来像这样可变数目: class Ring a where
addId :: a
addInverse :: a -> a
mulId :: a
add :: a -> a -> a
mul :: a -> a -> a
对于这个类我有几个实例,例如 instance Ring Matrix where ...
instanc
我有一堆的定义为QuickCheck特性如下: ...
prop_scaleData3 d n = n > 1 ⇛ length (scaleData d n) ≡ n
prop_scaleData4 d n = n > 1 ⇛ head (scaleData d n) ≡ -d
prop_scaleData5 d n = n > 1 ⇛ last (scaleData d n) ≡ d