[Haskell-cafe] Hoogle? [Stacking monads]

Mitchell, Neil neil.mitchell.2 at credit-suisse.com
Mon Oct 6 04:13:38 EDT 2008


Hi

> Try doing a Hoogle search for "c1 (c2 x) -> c2 (c1 x)". 
> Hoogle correctly states that Data.Traversable.sequence will 
> do it for you.
> 
> Now try doing "c1 k (c2 x) -> c2 (c1 k x)". The 'sequence' 
> function will also do this, but now Hoogle returns 0 results.
> 
> This is puzzling, since AFAIK, the above two type signatures 
> are "equvilent" in some sense. (Specifically, replace every 
> type X with type Y and you get from one to the other.) To me, 
> this looks like a Hoogle bug. (It goes without saying that 
> Hoogle also failed to find anything for the more specific 
> type signature I was searching for, despite the fact that 
> 'sequence' unifies with it.)

Hoogle is not a "unification engine" - since that is very rarely what
people want out of a type search engine. What it is is an approximate
matcher. Let's compare the two types:

Your search :: c1 k (c2 x) -> c2 (c1 k x)

sequence :: Monad m => [m a] -> m [a]

Are you expecting c1 (:: * -> * -> *) to unify with [] (:: * -> *)? That
seems kind incorrect at the very last. Additionally, those types don't
look all that close.

But, let's briefly consider unification (and why Hoogle doesn't used
it). Consider the search:

Eq a => [(a,b)] -> a -> b

What the user wants is lookup, which sadly doesn't unify. However,
undefined unifies perfectly.

Thanks

Neil


==============================================================================
Please access the attached hyperlink for an important electronic communications disclaimer: 

http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
==============================================================================



More information about the Haskell-Cafe mailing list