在哪里可以找到packages/modules的源代码?

Where can I find the source code of packages/modules?

我想看看Data.List或Data.Map等模块中定义的函数代码。

我可以用

导入 Data.List 模块
import Data.List

然后我可以使用函数 nubsort.

我想知道在哪里可以找到这些函数来查看它们的代码。

模块默认安装在哪个目录?

PS:Windows8.1,我安装了Haskell平台。

该目录包含已编译的模块,因此您无法在那里阅读源代码。

你可以做的是在online documentation中找到你的函数,然后点击右边的"Source"。

@arrowd notes in his answer,

That directory contains compiled modules, so you wouldn't be able to read the source there.

GHC repo (and its Github mirror)可以直接浏览,不过还有更简单的方法:

  1. 使用Hoogle or Stackage找到module/function所在的包

    请注意 Hoogle and Stackagecase-sensitive。 (最好用大写名称查找模块。)

    Hoogle yields a list similar to the one below. Stackage 中对 sort 的查询风格略有不同,但基本原理是相同的(主要是因为它使用 Hoogle 进行查找)。结果标题下的绿色线条显示包含

    的名称

    (1) 个包(小型大写字母)和

    (2) 个模块(大写)。

    可以有多个同名函数,但模块和包名称有助于选择正确的函数。

  2. 点击function/module名字

  3. 点击“#Source”