Skip to content

Commit 597c0ce

Browse files
Update for use with .ghc.environment files (#57)
This pull request updates HyperHaskell to work withe the latest ecosystem. In particular, * We support `.ghc.environment` files instead of the old way of `cabal` installing packages globally. * We update `Electron` to the latest version again. Fix #43
2 parents 5fda4d1 + 3addd89 commit 597c0ce

File tree

13 files changed

+77
-37
lines changed

13 files changed

+77
-37
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33

44
### HyperHaskell app bundle
55

6+
**v2.4.0** — Snapshot release.
7+
8+
* Works with `hyper-haskell-server` version 0.2.4.0.
9+
* Support `.ghc.environment` files.
10+
* Update Electron to version 38.2.2.
11+
612
**v2.3.0** — Snapshot release.
713

814
* Add `~/.ghcup` directory to PATH by default.
@@ -41,6 +47,13 @@
4147

4248
### `hyper-haskell-server` package
4349

50+
**v0.2.4.0**
51+
52+
* Works with HyperHaskell app version v2.4.0.
53+
* Less time to wait after interpreter starts up successfully.
54+
* Report slightly more errors.
55+
* Bump depenencies to allow `scotty-0.22`.
56+
4457
**v0.2.3.1** — Bump dependencies
4558

4659
**v0.2.3.0**
@@ -73,6 +86,8 @@
7386

7487
### `hyper-extra` package
7588

89+
**v0.2.0.2** — Bump dependencies, modernize `.cabal` file.
90+
7691
**v0.2.0.1** — Bump dependencies
7792

7893
**v0.2.0.0**
@@ -94,6 +109,8 @@
94109

95110
### `hyper` package
96111

112+
**v0.2.1.2** — Bump dependencies, modernize `.cabal` file.
113+
97114
**v0.2.1.1** — Bump dependencies
98115

99116
**v0.2.1.0**

README.md

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
[haskell]: https://haskell.org
1919
[show]: http://hackage.haskell.org/package/base/docs/Prelude.html#t:Show
2020
[display]: https://hackage.haskell.org/package/hyper/docs/Hyper.html#t:Display
21+
[cabal]: https://www.haskell.org/cabal/
2122
[ghc]: https://www.haskell.org/ghc/
2223
[electron]: http://electron.atom.io/
2324
[stack]: https://www.haskellstack.org
@@ -63,35 +64,56 @@ Installation from the binary distribution follows the structure explained above.
6364

6465
2. Install the back-end server
6566

66-
1. Make sure that you have a working installation of the [GHC][] Haskell compiler.
67+
1. Make sure that you have a working installation of
68+
69+
* the [Glasgow Haskell compiler (GHC)][ghc].
70+
* with [Cabal][] version **3.10** or higher.
6771

6872
2. Install the back-end with Cabal by executing
6973

70-
cabal install hyper hyper-haskell-server
74+
> cabal install hyper-haskell-server
75+
76+
3. Tell `hyper-haskell-server` about the Haskell packages that are in scope.
77+
78+
The `hyper-haskell-server` program will pick up the packages in scope from a [.ghc.environment][ghc-env] file. We follow the same logic as `ghci` on which file we pick up, where the current directory is the directory of the worksheet file.
79+
80+
There are two main ways to create a [.ghc.environment][ghc-env] file:
81+
82+
* Create a global environment file using `cabal install --lib`.
83+
* Create a local environment file for a given `.cabal` package using the `--write-ghc-environment-files=always` flag with `cabal configure`.
84+
85+
In both cases, the compilation of the `hyper` package in the environment file must match the compilation of the `hyper` package in `hyper-haskell-server` — this means identical versions of compiler and all dependencies!
86+
87+
In the short-term, it's easiest to work with the global environment file. Execute
88+
```
89+
> cabal install --lib diagrams diagrams-svg diagrams-lib hyper hyper-extra
90+
```
7191
72-
It is also recommended (but not necessary) that you install the additional support for other popular Haskell packages, e.g. the [Diagrams][] library by additionally executing
92+
in order to install the `hyper` package, as well as additional support for graphics via `hyper-extra` and [Diagrams][].
7393
74-
cabal install hyper-extra
94+
In the long-term, you may want to work with multiple local package environments. In this case, again, you have to make sure that `hyper-haskell-server` was compiled using `hyper` from this package environment.
7595
76-
3. Now you can start the front-end application and create a new worksheet, or open an existing one. Make sure that the "Interpreter Back-end" in the "Settings" section of the worksheet is set to "cabal". (The path field does not matter in this case.)
96+
4. Now you can start the front-end application and create a new worksheet, or open an existing one. Make sure that the "Interpreter Back-end" in the "Settings" section of the worksheet is set to "cabal". (The path field does not matter in this case.)
7797
7898
![Settings](docs/screenshots/settings-back-end-cabal.png)
7999
80-
It is also possible to use [Stack][] by using `stack install`, but that is not fully explained here, only to some extent below.
100+
It is also possible to use [Stack][] or [nix][nix], but that is not documented here.
81101
82102
That's it! Happy hyper!
83103
84104
[diagrams]: https://github.com/diagrams
105+
[ghc-env]: https://downloads.haskell.org/ghc/latest/docs/users_guide/packages.html#package-environments
106+
[nix]: https://nixos.org/download/
85107
86108
## Run from source
87109
88110
When developing HyperHaskell itself, it is also possible to run it from source. Follow these steps:
89111
90112
1. [Download and install Electron](http://electron.atom.io/releases/)
91113
92-
The whole thing is currently developed and tested with Electron version 10.1.5.
114+
The whole thing is currently developed and tested with Electron version 38.2.2.
93115
94-
(If you use the [npm][] package manager, you can install it in your home directory with `cd ~ && npm install electron@10.5.1`.
116+
(If you use the [npm][] package manager, you can install it in your home directory with `cd ~ && npm install electron@38.2.2`.
95117
On Debian-based Linux distributions, Electron [currently](https://github.com/electron-userland/electron-prebuilt/issues/70#issuecomment-192520913) requires the `nodejs-legacy` package.)
96118
97119
2. Make sure that you have a working installation of
@@ -139,19 +161,19 @@ We use the [`electron-packager`][pkg] utility. To install it, you need to use th
139161
140162
cd ~
141163
npm install electron-packager
142-
npm install electron@10.1.5 --save-dev
164+
npm install electron@38.2.2 --save-dev
143165
144166
To create an application bundle and compress it in a zip-file, use the following commands:
145167
146168
* On macOS:
147169
148-
make pkg-darwin
149-
make zip-darwin
170+
just pkg-darwin
171+
just zip-darwin
150172
151173
* On Windows: You need the [7zip](https://www.7-zip.org) utility in your path.
152174
153-
make pkg-win32
154-
nake zip-win32
175+
just pkg-win32
176+
just zip-win32
155177
156178
* On Linux: not implemented yet
157179

app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "HyperHaskell",
3-
"version": "2.3.1",
3+
"version": "2.4.0",
44
"main": "src/main.js",
55
"devDependencies": {
6-
"electron": "^31.4.0"
6+
"electron": "^38.2.2"
77
}
88
}

app/src/interpreter-worksheet.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ window.newInterpreter = () => {
110110
that.loadImports = (config, cont) => {
111111
console.log('interpreter.loadImports')
112112
const doImports = () => {
113-
console.log('interpreter.doImports')
113+
console.log('interpreter.doImports', JSON.stringify(config))
114114
loadImports(config, cont)
115115
}
116116
if ( config.packagePath !== packagePath

app/src/interpreter.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ exports.init = () => {
7070
// setup environment
7171
let env = {}
7272
env['HOME'] = app.getPath('home') // necessary for finding package database
73-
// FIXME: Where to we get the path from as a standalone application?
73+
// FIXME: Where do we get the path from as a standalone application?
7474
// pick up path from external environment if possible
7575
env['PATH'] = lib.process.env['PATH'] + ':/usr/bin:/usr/local/bin:' + env['HOME'] + '/.ghcup/bin'
7676
env['PORT'] = port.toString()
@@ -88,13 +88,18 @@ exports.init = () => {
8888
if (isWindows) {
8989
cmd = env['HOME'] + '\\AppData\\Roaming\\cabal\\bin\\hyper-haskell-server'
9090
} else {
91-
cmd = env['HOME'] + '/.cabal/bin/hyper-haskell-server'
91+
// cmd = env['HOME'] + '/.cabal/bin/hyper-haskell-server'
92+
// Cabal >= 3.10 installs binaries in ~/.local/bin by default.
93+
cmd = env['HOME'] + '/.local/bin/hyper-haskell-server'
9294
}
9395
} else if (packageTool == 'cabal.project') {
9496
cmd = 'cabal'
95-
// FIXME: Add cabal project dir that is relative to the current worksheet
97+
// FIXME?: Add cabal project dir that is relative to the current worksheet
9698
// args = ['exec', '--project-dir', lib.path.dirname(packagePath), 'hyper-haskell-server']
97-
args = ['exec', 'hyper-haskell-server']
99+
// NOTE: We use 'exec' instead of 'run' because we expect
100+
// the developer to have build the executable 'hyper-haskell-server'.
101+
// Using 'run' may change .ghc.environment files.
102+
args = ['exec', 'hyper-haskell-server']
98103
} else if (packageTool == 'nix') {
99104
cmd = 'hyper-haskell-server'
100105
env = Object.assign({}, lib.process.env, { PORT: port.toString() })

app/worksheet.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ <h1 class="closed">Settings</h1>
3131
<p>
3232
<label for="packagePath">Interpreter Back-end:</label>
3333
<select id="packageTool" size="1">
34-
<option value="cabal">cabal — (default paths) </option>
35-
<option value="cabal.project">cabal — cabal.project</option>
34+
<option value="cabal">cabal — .ghc.environment</option>
3635
<option value="stack">stack — stack.yaml</option>
3736
<option value="nix">nix</option>
37+
<option value="cabal.project">(development — cabal.project)</option>
3838
</select>
3939
<input id="packagePath" type="text" value="">
4040
<p>The search path is used when a source file uses <code>import</code> and additional source files need to be located and interpreted.
11.5 KB
Loading

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,7 @@
4343

4444
pkgs.nodejs_22
4545
pkgs.electron
46-
] ++ lib.optionals pkgs.stdenv.isDarwin ([
47-
pkgs.darwin.apple_sdk.frameworks.Cocoa
48-
pkgs.darwin.apple_sdk.frameworks.CoreServices
49-
pkgs.darwin.objc4.all
50-
]);
46+
];
5147
};
5248

5349
shellHook = ''

haskell/hyper-extra/hyper-extra.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ tested-with:
2727

2828
source-repository head
2929
type: git
30-
location: git://github.com/HeinrichApfelmus/hyper-haskell.git
30+
location: https://github.com/HeinrichApfelmus/hyper-haskell.git
3131
subdir: haskell/hyper-extra/
3232

3333
library
@@ -38,7 +38,7 @@ library
3838
, diagrams-lib >= 1.3 && < 1.6
3939
, diagrams-svg >= 1.4 && < 1.6
4040
, hyper >= 0.2 && < 0.3
41-
, QuickCheck >= 2.3.0.2 && < 2.16
41+
, QuickCheck >= 2.3.0.2 && < 2.18
4242
, svg-builder >= 0.1 && < 0.2
4343
, text >= 0.11 && < 2.2
4444
exposed-modules:

0 commit comments

Comments
 (0)