Haskell hack: find the function you need with Hoogle.

antonrich

Anton

Posted on October 28, 2018

Haskell hack: find the function you need with Hoogle.

Today I was solving a problem on Codewars. I somehow forgot about a very simple function that can check if an element is a member of a list.

Alt searching for a Haskell function

This of course led me to stackoverflow. You can find an interest hack there that was posted by AtnNn:

First find the type of the function you need.

To "Check if" means to return either True or False, a Bool.

So the function takes an Int, a list of Int (aka [Int]) and returns Bool:

Int -> [Int] -> Bool

Now ask hoogle.

elem :: Eq a => a -> [a] -> Bool

Hoogle is a very useful tool. You can integrate it with ghci.


This hack to use type signatures on Hoogle is such a wonderful thing. It makes Haskell even more intuitive.

What kind of Haskell hacks do you use?

P.S. If I remembered the function "elem" I wouldn't probably find out about that hack for a long time.

💖 💪 🙅 🚩
antonrich
Anton

Posted on October 28, 2018

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related