Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 3 additions & 39 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,49 +36,13 @@ defaults: &defaults

version: 2
jobs:
ghc-8.0.2:
ghc-9.10.2:
environment:
- STACK_FILE: "stack-8.0.2.yaml"
<<: *defaults

ghc-8.2.2:
environment:
- STACK_FILE: "stack-8.2.2.yaml"
<<: *defaults

ghc-8.4.3:
environment:
- STACK_FILE: "stack-8.4.3.yaml"
<<: *defaults

ghc-8.4.4:
environment:
- STACK_FILE: "stack-8.4.4.yaml"
<<: *defaults

ghc-8.6.3:
environment:
- STACK_FILE: "stack-8.6.3.yaml"
<<: *defaults

ghc-8.6.4:
environment:
- STACK_FILE: "stack-8.6.4.yaml"
<<: *defaults

ghc-8.6.5:
environment:
- STACK_FILE: "stack-8.6.5.yaml"
- STACK_FILE: "stack-9.10.2.yaml"
<<: *defaults

workflows:
version: 2
build_and_test:
jobs:
- ghc-8.0.2
- ghc-8.2.2
- ghc-8.4.3
- ghc-8.4.4
- ghc-8.6.3
- ghc-8.6.4
- ghc-8.6.5
- ghc-8.10.2
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,14 @@ TAGS
.\#*
# stack 2.1 stack.yaml lock files
stack*.yaml.lock

*.hi
*.o
.vscode

.DS_Store

*.dyn_hi
*.dyn_o

vendor
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "vendor/ghc"]
path = vendor/ghc
url = https://gitlab.haskell.org/ghc/ghc.git
77 changes: 38 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Examples:

![Haskell Code Explorer](https://haskell-code-explorer.mfix.io/screenshot.png)

- for 9.10.2 [http://www.haskell.fan](http://www.haskell.fun)

The public instance of Haskell Code Explorer is available at [https://haskell-code-explorer.mfix.io](https://haskell-code-explorer.mfix.io). It contains core libraries (ghc, base, etc.) and a subset of packages from a Stackage snapshot.

Haskell Code Explorer consists of an indexer, an HTTP server, and a JavaScript application. The indexer uses GHC API to create a data structure that contains detailed information about the source code of a Cabal package. The HTTP server reads that data structure into memory and responds to HTTP requests from the JavaScript application.
Expand Down Expand Up @@ -39,57 +41,31 @@ Reading and understanding code is an essential part of the software development

* Semantic highlighting

## Installation
## Installing
At the moment Haskell Code Explorer supports GHC 9.10.2

```bash
git clone https://github.com/alexwl/haskell-code-explorer
cd haskell-code-explorer
```

To build Haskell Code Explorer Stack ([https://docs.haskellstack.org/en/stable/README/](https://docs.haskellstack.org/en/stable/README/)) is needed.

At the moment Haskell Code Explorer supports GHC 8.6.5, 8.6.4, GHC 8.6.3, GHC 8.4.4, GHC 8.4.3, GHC 8.2.2, and 8.0.2.

For GHC 8.6.5:
For GHC 9.10.2:

```bash
stack install
```

For GHC 8.6.4:
For GHC 9.10.2:

```bash
stack --stack-yaml=stack-8.6.4.yaml install
stack --stack-yaml=stack-9.10.2.yaml install
```

For GHC 8.6.3:

```bash
stack --stack-yaml=stack-8.6.3.yaml install
```

For GHC 8.4.4:

```bash
stack --stack-yaml=stack-8.4.4.yaml install
```

For GHC 8.4.3:

```bash
stack --stack-yaml=stack-8.4.3.yaml install
```

For GHC 8.2.2:

## Debugging
Modify `haskell-code-explorer` and `vendor/ghc/compiler`.
Modify `index` script
```bash
stack --stack-yaml=stack-8.2.2.yaml install
```

For GHC 8.0.2:

```bash
stack --stack-yaml=stack-8.0.2.yaml install
sudo chmod 777 index
./index
```

## Indexing source code of a Cabal package
Expand All @@ -100,18 +76,35 @@ A package should be built using either cabal-install or stack before indexing (`

The version of GHC used to build `haskell-code-indexer` must match the version of GHC used to build a package you are indexing (to find out the version of GHC try `ghc --version` or `stack exec ghc -- --version` command).

`haskell-code-indexer` requires globally installed GHC and cabal-install (`cabal`). The reason for this is that `haskell-code-indexer` uses `cabal-helper` library [https://hackage.haskell.org/package/cabal-helper](https://hackage.haskell.org/package/cabal-helper) to get package build information. `cabal-helper` builds (at runtime) an executable linked against a version of Cabal library that was used to configure the package. You may need to run `cabal update` to get the latest list of available packages to be able to build the `cabal-helper` executable. By default, the `cabal-helper` executable (e.g.,`cabal-helper0.8.1.2-Cabal2.4.1.0`) is saved to `$HOME/.cache/cabal-helper`.
`haskell-code-indexer` requires globally installed GHC and cabal-install (`cabal`). The reason for this is that `haskell-code-indexer` uses `cabal` library to get package build information.

If there is no globally installed GHC on the system, then it is possible to use `stack exec` command ([https://docs.haskellstack.org/en/stable/GUIDE/#exec](https://docs.haskellstack.org/en/stable/GUIDE/#exec)) that adds a path to GHC binaries installed by Stack to `PATH` environment variable.

Unify snapshot of stackage. For ghc 9.10.2, using lts-24.11
```
resolver: lts-24.11
```

Build All targets
```
stack ide targets
stack build --test --bench
```

Run `cabal update` using stack exec:
```bash
stack --resolver=lts-13.20 exec --no-ghc-package-path cabal -- update
stack --resolver=lts-24.11 exec --no-ghc-package-path cabal -- update
```

Index a package using stack exec:
```bash
stack --resolver=lts-13.20 exec --no-ghc-package-path haskell-code-indexer -- INDEXER_OPTIONS
stack --resolver=lts-24.11 exec --no-ghc-package-path haskell-code-indexer -- INDEXER_OPTIONS
```

Or modify and execute `index` script
```bash
sudo chmod 777 index
./index
```

`--no-ghc-package-path` option unsets `GHC_PACKAGE_PATH` environment variable. `cabal` fails with the error `Use of GHC's environment variable GHC_PACKAGE_PATH is incompatible with Cabal.` if the `GHC_PACKAGE_PATH` is set.
Expand Down Expand Up @@ -157,6 +150,12 @@ Load multiple indexed packages and start the server:
haskell-code-server --package PATH1 --package PATH2 --package PATH3 --port 8080
```

Or modify or execute `server` script
```bash
sudo chmod 777 server
./server
```

Load the indexed package and start the server, use Hoogle API (https://github.com/ndmitchell/hoogle/blob/3dbf68bfd701f942d3af2e6debb74a0a78cd392e/docs/API.md#json-api) to get documentation for functions and types defined in other packages (`haskell-code-server` makes requests to https://hoogle.haskell.org/):

```bash
Expand Down
5 changes: 3 additions & 2 deletions app/Indexer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import qualified Data.Serialize as S
import qualified Data.Text as T
import qualified Data.Text.Encoding as TE
import Data.Time (getZonedTime)
import Data.Version (showVersion)
import Data.Version (showVersion, Version(..))
import HaskellCodeExplorer.PackageInfo (createPackageInfo, ghcVersion)
import qualified HaskellCodeExplorer.Types as HCE
import Network.URI.Encode (encode)
Expand All @@ -43,6 +43,7 @@ import Options.Applicative
, value
)
import Paths_haskell_code_explorer as HSE (version)
import Prelude
import System.Directory (createDirectoryIfMissing)
import System.Exit (ExitCode(..), exitWith)
import System.FilePath ((</>))
Expand Down Expand Up @@ -105,7 +106,7 @@ main = do
(configPackageDirectoryPath config)
(configPackageDistDirRelativePath config)
(configSourceCodePreprocessing config)
(configGhcOptions config)
((configGhcOptions config) <> [T.unpack "-DHASKELL_CODE_INDEXER"])
(configIgnoreDirectories config))
(\_loc _source level msg -> logger loggerSet minLogLevel level msg)
let outputDir =
Expand Down
Loading