Reputation:
I would like to look at the code of functions defined in modules, such as Data.List or Data.Map.
I can import Data.List module with
import Data.List
and then I can use the functions nub
or sort
.
I would like to know where I can find these functions to look at their code.
In which directory are the modules installed by default?
PS: Windows 8.1, I installed Haskell Platform.
Upvotes: 1
Views: 832
Reputation: 8303
As @arrowd notes in his answer,
That directory contains compiled modules, so you wouldn't be able to read the source there.
The GHC repo (and its Github mirror) can be directly browsed, but there is an easier way:
Use Hoogle or Stackage to find the package where the module/function resides
Note that Hoogle and Stackage are case-sensitive. (It's best to look up modules with their capitalized names.)
A query for sort
in Hoogle yields a list similar to the one below. Stackage has a slightly different style, but the basics are the same (mostly because it uses Hoogle for lookup). The lines in green under the result headings show the name(s) of the containing
(1) package(s) (in small caps) and
(2) module(s) (capitalized).
There can be multiple functions with the same name, but the module and package name helps to choose the right one.
Click on the function/module name
Click on "#Source"
Upvotes: 1
Reputation: 34411
That directory contains compiled modules, so you wouldn't be able to read the source there.
What you can do is to find your function in online documentation and then click "Source" on the right.
Upvotes: 3