Haskell hack: find the function you need with Hoogle.
Anton

Anton @antonrich

About: Born into being.

Location:
Russia, Yoshkar-Ola
Joined:
Oct 5, 2017

Haskell hack: find the function you need with Hoogle.

Publish Date: Oct 28 '18
10 0

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.

Comments 0 total

    Add comment