ndmitchell / hoogle

Haskell API search engine
http://hoogle.haskell.org/
Other
753 stars 137 forks source link

Regular Expression in text searches? #199

Open RasmusWL opened 7 years ago

RasmusWL commented 7 years ago

First off, thanks for all the hard work! Hoogle has helped me out many times :)

I just came across a problem of converting from one datatype to another. Hoogle to the rescue! -- stack hoogle ':: SubExp -> PrimExp'

However, as this gave me many results, I wanted to narrow down to functions that contained either to or from in their name. However, I needed to do two searches stack hoogle 'to :: SubExp -> PrimExp' and stack hoogle 'from :: SubExp -> PrimExp' to achive that.

It could be nice if I could do the following: stack hoogle '(to|from) :: SubExp -> PrimExp'

I guess allowing regular expressions for type searching would be a mess, so I'm guessing there might be some caveats, but I wanted to hear your thoughts on it anyway.


edit: from the commandline I can actually just use grep, but from the web interface it is not that easy.

ndmitchell commented 7 years ago

Not sure regex is required - what about "to from :: A -> B" with the rule that ones with only one named match rank lower but are still displayed?

RasmusWL commented 7 years ago

Thanks for getting back to me. I just tried this locally, on haskell.org/hoogle/, and hoogle.haskell.org but none of them came up with any result for the query "to from :: A -> B". However, they all found multiple result from just "to :: A -> B" and "from :: A -> B"

Am I doing something wrong?

ndmitchell commented 7 years ago

Sorry, was typing on a mobile device, and totally forgot to write my main point. What I'm saying is if there was a change so that "to from" was treated as OR rather than AND (with a higher ranking for AND matches) then you'd have everything you want, and it would be simpler than adding regex support. That would be a change from current behaviour, and is what I'm proposing to solve your problem. Does that make sense?

RasmusWL commented 7 years ago

Ahh, now I understand :)

think this could be useful, as long as AND matches are always are ranked higher, I don't see how it could upset anyone.