Commit Graph

35 Commits

Author SHA1 Message Date
Richard Marko b84f4f6c19 repl: Support loading .hnixrc from current directory 2020-07-04 18:42:16 +02:00
Richard Marko f7704b4c28 repl: Pass result of --eval -E "..expr.." to REPL
Allows us to do
```
hnix --eval -E '{ a = 2; b = "test"; }' --repl

hnix> :browse
input = { a = 2; b = "test"; }
hnix> input.a
2
hnix> input.b
"test"
```

Closes #292.
2020-07-04 18:42:16 +02:00
Richard Marko 4ce176d1a1 repl: Better help using HelpOption type 2020-07-04 18:42:16 +02:00
Richard Marko 0e8e73ec88 repl: Extend IState, handle bindings, add browse and debug commands
Bindings are now handled correctly and you can do

```
a = 2
b = 3
c = a + b
:browse
:t c
```

Converted IState to data type instead of `newtype`.
Now tracks `replIt` for last entered expression that parsed
successfully.

`replCtx` is now extended with bindings and browseable via `:browse`.

:`debug` can be used to enable dumping of `IState` on input.

Scope taken from `replCtx` is now pushed to evaluated values.
2020-07-04 18:42:16 +02:00
Richard Marko d9303f385c repl: Refactor error handling
Drops Repline `abort`s and switches to `Maybe` result for `call` function.

Few other bits handled too:
- `M.empty` -> `mempty`
- qualified use of `Data.Text`
- minor formatting fixes for readability

Closes #505.
2020-07-04 18:42:16 +02:00
Richard Marko 59e65d094a repl: support multi-line input
```
Welcome to hnix 0.9.0. For help type :help

hnix> :paste
-- Entering multi-line mode. Press <Ctrl-D> to finish.
| { just
| =
| ''
| testing
| '';
| }
|
{ just = "<CYCLE>"; }
hnix>
Goodbye.
```

Closes #665.
2020-07-02 14:04:13 +02:00
Richard Marko 710bc84309 Support repline 0.4
Closes #651.

`haskeline` override needs `dontCheck` as it tries to run an executable.

Tested build and repl itself.
2020-07-02 14:04:13 +02:00
Anton-Latukha 76ab909958
clean-up Monoid imports
M  main/Repl.hs
M  src/Nix/Expr/Strings.hs
M  src/Nix/Utils.hs
2020-06-02 02:11:50 +03:00
Simon Jakobi 9c6003ae8b
Use haskeline-0.8 (#540)
The `MonadException` class was removed in favor of `MonadCatch`, so we
can remove its instances, enabling us to remove the library dependency
on haskeline.

To simplify dependency resolution with GHC < 8.10, this also disables
the executable in that configuration.
2020-05-30 03:32:20 +02:00
Anton Latukha 86b5da1fa1
Repl.hs: import: Repline: hide options (#582)
Report: https://github.com/haskell-nix/hnix/issues/538#issue-581377935

M  main/Repl.hs
2020-05-25 21:47:02 +03:00
Anton-Latukha c67fa20aed Repl: LANGUAGE: rm LambdaCase 2019-08-04 09:14:41 -07:00
John Wiegley 4607639774 Remove the NValueNF type, as it provides little utility 2019-03-27 21:16:01 -07:00
John Wiegley 9b046a80c7
Remove unnecessary trailing space 2019-03-18 21:41:27 -07:00
John Wiegley 2c0c896871
Everything compiling again, but 25 tests failing 2019-03-18 17:30:31 -07:00
John Wiegley aa66560bf7
Get rid of implicit conversions to and from thunks 2019-03-17 15:30:20 -07:00
John Wiegley 94e0be3882
Reformat all sources with Brittany, to restore consistency 2019-03-17 14:47:38 -07:00
John Wiegley e9236aa55c
Now down to Main.hs and the tests 2019-03-15 17:20:10 -07:00
John Wiegley f397b80a9c Factor out citation information to its own data structure 2019-03-10 16:07:13 -07:00
Jörg Thalheim 8b10c79e41
improve hnix REPL help
all commands needs to prefixed by :
2019-01-27 20:07:43 +00:00
Domen Kožar 51d493f484
Fix compilation 2018-11-25 10:01:14 +00:00
Domen Kožar c450af4dcd
repl: add welcome text and :help command 2018-11-24 20:17:45 +00:00
Domen Kožar b0f346fc5a
Fix GHC 8.6 compilation 2018-11-23 13:43:36 +00:00
Domen Kožar 0c9aef937b
add typeof to repl 2018-11-23 13:30:19 +00:00
Domen Kožar 58a83622eb
GHC 8.6 support 2018-11-20 23:44:59 +00:00
Ryan Trinkle 32850cd23e Factor out instantiate and exec 2018-11-16 21:30:51 -05:00
John Wiegley b186e44174
--force was a needless duplicate of --strict 2018-05-09 13:52:34 -07:00
John Wiegley 60406a8ce5 Improve error reporting and value display in the REPL 2018-04-28 17:13:17 -07:00
John Wiegley 100c41db6d Run the repl in the same MonadNix environment as Main.hs
Fixes #204
2018-04-28 16:26:32 -07:00
John Wiegley 8a93068102 Rename Nix.Core back to Nix.Eval, since Nix.Eval was now almost empty 2018-04-21 10:11:34 -07:00
John Wiegley 86b09103d6 Move production of a reduced test case to --reduce, improve --trace 2018-04-20 22:36:40 -07:00
John Wiegley c3f34e62ce Use verbosity to control how much is displayed in error messages 2018-04-17 17:25:59 -07:00
John Wiegley 4f17250d11 More simplifying of imports 2018-04-14 09:44:55 -07:00
John Wiegley 58b65d2ce1 Don't evaluate to normal form by default in the top level evaluators 2018-04-13 19:29:18 -07:00
John Wiegley 99189e9536 The basic REPL now works; doesn't allow establishing definitions yet 2018-04-12 16:46:34 -07:00
John Wiegley 709cc5247e Add code for doing Hindley-Milner type inference, and a repl
This code was written by Stephen Diehl and Kwang Yul Seo, which they released
under an MIT license as the project poly_constraints:

    https://github.com/kseo/poly_constraints

The code is added to hnix right now as mainly a placeholder, and will need to
be modified before it can be used.
2018-04-12 10:53:50 -07:00