简体   繁体   English

为什么类型f(fbc)(f(fab)(fac))不匹配(。)?

[英]Why doesn't the type f (f b c) (f (f a b) (f a c)) match (.)?

I have just formulated the type of (.) , generalized, as far as I can tell, however, upon typing it into Hoogle , I received no results. 据我所知,我只是制定了(.)的类型,但是将其键入Hoogle时 ,没有得到任何结果。

I'd have expected 我曾期望

(.) :: (->) ((->) b c) ((->) ((->) a b) ((->) a c))
     ~ (b -> c) -> ((a -> b) -> (a -> c))
     ~ (b -> c) -> (a -> b) -> a -> c

to match 匹配

thistype ~ f (f b c) (f (f a b) (f a c))

The technical answer is that Hoogle splits the search into arguments and return types on the outer (->) parts, and then searches for each part individually, before combining the results. 技术上的答案是,Hoogle将搜索分为外部(->)部分的参数和返回类型,然后在组合结果之前分别搜索每个部分。 The outer (->) is treated very specially, in particular it's happy to reorder arguments. 外部(->)的处理方式非常特殊,特别是对参数重新排序很高兴。

The more fundamental reason why Hoogle works this way is that it's a search engine, not a unification engine. Hoogle采用这种方式的更根本原因是它是搜索引擎,而不是统一引擎。 If you were searching for the above, and got back (.) , would that have answered your question? 如果您正在搜索以上内容,然后返回(.) ,那将回答您的问题吗? My guess is probably not. 我的猜测可能不是。 My favourite example is that searching for "a -> [(a,b)] -> b" should return lookup , even though it doesn't unify. 我最喜欢的示例是搜索"a -> [(a,b)] -> b"应该返回lookup ,即使它没有统一。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Functor用于(a - &gt; b) - &gt;(fa - &gt; fb),什么是(类别c)=&gt; cab - &gt; c(fa)(fb)? - Functor is for (a -> b) -> (f a -> f b), what is for (Category c) => c a b -> c (f a) (f b)? 为什么在 Applicative 上 pure 的类型是 a -> fa,而不是 (a -> b) -> f (a -> b)? - Why type of pure is a -> f a, not (a -> b) -> f (a -> b) on Applicative? 如果f是a-&gt; b类型的函数,则(fmap f)与(f。)相同吗? - Is (fmap f) the same as (f .) if f is a function of type a->b? ((fa)b)与Haskell中的(fab)相同吗? - Is ((f a) b) the same as (f a b) in Haskell? bi fab的通用变体=(fa,fb) - Generic variant of bi f a b = (f a, f b) Haskell:是否有这样的运算符:(&lt;$$&gt;):: Functor f =&gt; fa-&gt;(a-&gt; b)-&gt; fb - Haskell: Is there an operator like this: (<$$>) :: Functor f => f a -> (a -> b) -> f b 为什么f =(+)不需要类型注释? - Why doesn't f=(+) need a type annotation? f, g, h :: Kleisli ((-&gt;) e) ab &lt;=&gt; f &gt;&gt;&gt; (g &amp;&amp;&amp; h) = (f &gt;&gt;&gt; g) &amp;&amp;&amp; (f &gt;&gt;&gt; h)? - f, g, h :: Kleisli ((->) e) a b <=> f >>> (g &&& h) = (f >>> g) &&& (f >>> h)? (&lt;*&gt;):: f(a-&gt; b)-&gt; fa-&gt; fb在Functor类中到底做了什么 - what does (<*>) :: f (a -> b) -> f a -> f b exactly do in the Functor class 解决`f = f(&lt;*&gt;)pure`的类型 - Resolving the type of `f = f (<*>) pure`
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM