Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How library functions in Haskell are implemented

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).

like image 860
Mitch Phillipson Avatar asked Dec 12 '11 17:12

Mitch Phillipson


2 Answers

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.

like image 80
C. A. McCann Avatar answered Oct 14 '22 17:10

C. A. McCann


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.

like image 21
vis Avatar answered Oct 14 '22 18:10

vis