[英]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.