12
votes

I'm just starting to learn Haskell and would find it very helpful to see how Haskell functions are implemented. I've been able to find the Standard Prelude on different question, but I'm now interested in Data.List. Is there any way to find the source for these functions?

I would really like to see permutations and nub (and the rest, but these are the most interesting for me right now).

3

3 Answers

24
votes

Here you go: http://hackage.haskell.org/packages/archive/base/latest/doc/html/src/Data-List.html

More generally, if you look at the documentation page for Data.List you'll see "Source" links to the right of the type signatures, which will take you directly to the source for that function.

You can find the source for the rest of the standard libraries the same way and, in fact, for nearly everything on Hackage.

8
votes

The documentation of the Data.List module is found here: http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-List.html

And the source here: http://www.haskell.org/ghc/docs/latest/html/libraries/base/src/Data-List.html

In GHCI, you can do :browse Data.List to find more about this module. Note that the basic list definitions and operations are also found in base packages e.g. GHC.Base, GHC.List.

0
votes

Other links shared did not work for me, check this out

http://hackage.haskell.org/package/base-4.12.0.0/docs/src/Data.List.html

"Source" link is to the top right of the page.

To view any function implementation click on it.