简体   繁体   中英

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.

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. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM