QuickCheck的推广功能的一般情况是什么? [英] What is the general case of QuickCheck's promote function?
问题描述
具有类似于QuickCheck的促进
函数的结构的函子的一般术语是什么,即函数的形式如下:
promote ::(a - > fb) - > f(a - > b)
(这是翻转的倒数$ fmap(flip($)):: f(a - > b) - >(a - > fb)
)。除了( - >)r
和 Id
以外,是否还有使用这种操作的函数? (我确定必须有)。谷歌搜索'quickcheck promotion'只是提供了QuickCheck文档,该文档在任何更一般的上下文AFAICS中都没有给出 promote
;搜索SO for'quickcheck promote'不会产生任何结果。
到目前为止,我发现了构建 f
与宣传
态度:
-
f = Identity
- 如果f和g都有
promote
ht =(ft,gt)
如果f和g都有promote $ c>,那么
- $ c>,那么如果f的
ht = f(gt)
也是
- / code>属性,g是任何反函数函数,则函数
ht = gt - > ft
具有宣传
属性
- $ c>,那么如果f的
财产可以推广到profunctors g,但然后f将只是一个整数,所以它可能不是很有用,除非你只需要profunctors。
现在,使用这四个我们可以找到许多函数的例子 f
,其中 promote
存在:
pre $ code> ft =(t,t)
ft =(t,b - > t)
ft =( t - > a) - > t
f t =((t,t) - > b) - > (t,t,t)
f t =((t,t,c-> t,(t-> b) - > t) - > a) - > t
另请注意,宣传
属性意味着指出 f
。
point :: t - > ft
point x = fmap(const x)(promote id)
基本上是同一个问题:函子的这个属性是否比单子更强?
What is the general term for a functor with a structure resembling QuickCheck's promote
function, i.e., a function of the form:
promote :: (a -> f b) -> f (a -> b)
(this is the inverse of flip $ fmap (flip ($)) :: f (a -> b) -> (a -> f b)
). Are there even any functors with such an operation, other than (->) r
and Id
? (I'm sure there must be). Googling 'quickcheck promote' only turned up the QuickCheck documentation, which doesn't give promote
in any more general context AFAICS; searching SO for 'quickcheck promote' produces no results.
So far I found these ways of constructing an f
with the promote
morphism:
f = Identity
- if f and g both have
promote
then the pair functorh t = (f t, g t)
also does - if f and g both have
promote
then the compositionh t = f (g t)
also does - if f has the
promote
property and g is any contrafunctor then the functorh t = g t -> f t
has thepromote
property
The last property can be generalized to profunctors g, but then f will be merely a profunctor, so it's probably not very useful, unless you only require profunctors.
Now, using these four constructions, we can find many examples of functors f
for which promote
exists:
f t = (t,t)
f t = (t, b -> t)
f t = (t -> a) -> t
f t = ((t,t) -> b) -> (t,t,t)
f t = ((t, t, c -> t, (t -> b) -> t) -> a) -> t
Also note that the promote
property implies that f
is pointed.
point :: t -> f t
point x = fmap (const x) (promote id)
Essentially the same question: Is this property of a functor stronger than a monad?
这篇关于QuickCheck的推广功能的一般情况是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!