Commit Graph

106 Commits

Author SHA1 Message Date
Anton-Latukha 3774516033
clean-up: Main 2020-09-21 01:57:58 +03:00
Anton-Latukha 10051fbfc1
clean-up: rm commented-out imports
M  main/Main.hs
M  src/Nix/Reduce.hs
M  src/Nix/Type/Infer.hs
M  tests/EvalTests.hs
2020-09-21 01:57:58 +03:00
Anton-Latukha 0cb3946ee7
clean-up: (return -> pure)
M  main/Main.hs
M  main/Repl.hs
M  src/Nix/Builtins.hs
M  src/Nix/Convert.hs
M  src/Nix/Effects.hs
M  src/Nix/Effects/Basic.hs
M  src/Nix/Eval.hs
M  src/Nix/Exec.hs
M  src/Nix/Expr/Types.hs
M  src/Nix/Json.hs
M  src/Nix/Lint.hs
M  src/Nix/Normal.hs
M  src/Nix/Options/Parser.hs
M  src/Nix/Parser.hs
M  src/Nix/Scope.hs
M  src/Nix/String.hs
M  src/Nix/TH.hs
M  src/Nix/Thunk/Basic.hs
M  src/Nix/Utils.hs
M  src/Nix/Value.hs
M  src/Nix/Value/Equal.hs
M  src/Nix/XML.hs
M  tests/EvalTests.hs
M  tests/Main.hs
M  tests/NixLanguageTests.hs
M  tests/ParserTests.hs
M  tests/TestCommon.hs
2020-09-21 01:57:52 +03:00
Simon Jakobi 93ecf531c4 Remove overlapping [From,To]JSON instances for NExpr
…for compatibility with aeson-1.5.3.

Closes #690.
2020-08-19 15:22:33 -07:00
Simon Jakobi 1a2d627a58 Use prettyprinter-1.7.0
Changelog:
http://hackage.haskell.org/package/prettyprinter-1.7.0/changelog

hnix is likely to be affected by this change:

> Use floor instead of round to compute ribbon width.

…due to its use of custom `LayoutOptions`.
2020-08-07 12:21:12 +03: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
John Wiegley 4607639774 Remove the NValueNF type, as it provides little utility 2019-03-27 21:16:01 -07:00
John Wiegley 04cf8be650
Move StdIdT out of the StandardT transformer 2019-03-23 00:56:40 -07:00
John Wiegley 77c52fd43c Revise Nix.Standard 2019-03-23 00:49:03 -07:00
John Wiegley d1ada44817
Run brittany 2019-03-18 21:47:43 -07:00
John Wiegley 2c0c896871
Everything compiling again, but 25 tests failing 2019-03-18 17:30:31 -07:00
John Wiegley a006769124
Factor some common patterns back into Standard 2019-03-17 21:58:35 -07:00
John Wiegley 7b5d134d22
Factor out FreshIdT from Standard 2019-03-17 19:04:38 -07:00
John Wiegley 015ced236e
Simplify Standard by splitting off Cited.Basic 2019-03-17 18:43:23 -07:00
John Wiegley 94e0be3882
Reformat all sources with Brittany, to restore consistency 2019-03-17 14:47:38 -07:00
John Wiegley 6e4a3de15c
Remove a comment that is no longer necessary 2019-03-16 16:10:34 -07:00
John Wiegley 6ae5764221
All type checks, but many instance definitions are still missing 2019-03-16 01:10:47 -07:00
John Wiegley 145e69c9a4
Further work on Standard.hs 2019-03-15 22:54:29 -07:00
John Wiegley 107f29d3fd
Move certain constraints from MonadThunk to the BasicThunk instance 2019-03-11 13:55:40 -07:00
John Wiegley 39fd51c1a8 Split Nix.Thunk into Nix.Var, Nix.Thunk and Nix.Thunk.Basic
This is in preparation for further generalization of the thunk/value scheme
used by the execution code.
2019-03-11 08:42:46 -07:00
John Wiegley f397b80a9c Factor out citation information to its own data structure 2019-03-10 16:07:13 -07:00
Ken Micklas ad0d2d2bf8 Use WithStringContext(T) for nvalueToJSON 2018-12-13 16:59:51 -05:00
Ken Micklas 824615aabe Merge branch 'master' into xml-string-context 2018-12-10 15:48:29 -05:00
Doug Beardsley 7d2f9d874a Move json code into separate module 2018-12-09 13:57:58 -05:00
Ken Micklas 810821087a Fix hnix exe type error 2018-12-07 17:02:38 -05:00
Shea Levy 2bba6c84e6
Revert "Fix compilation"
This fix isn't necessary now that the XML context change is
reverted.

This reverts commit 51d493f484.
2018-11-27 14:22:04 -05: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
John Ericson 04abd357bd Switch to prettyprinter 2018-11-17 12:02:26 -05:00
John Wiegley 582a2b0a76
Make 'builtins' available in the repl 2018-08-04 17:34:50 -04:00
John Wiegley b186e44174
--force was a needless duplicate of --strict 2018-05-09 13:52:34 -07:00
John Wiegley ba0dc19d2d
Work from mightybyte: Minimize deps required, for building with GHCJS 2018-05-08 16:41:15 -07:00
John Wiegley 1a376598a6
Pretty print expressions when using -v5 and just --parse 2018-05-06 22:13:44 -07:00
hsloan c1561ea711 Implement builtins.currentTime 2018-05-02 21:32:00 -07:00
John Wiegley fe4629c3a4 More fixes to type inference 2018-05-02 15:08:53 -07:00
John Wiegley ee8ba02dfd Much more work on type inference; report multiple possible types
This is needed because of a function like this:

    x: y: x + y

This is polymorphic, but over exactly four possibilities:

    int   -> int
    int   -> float
    float -> int
    float -> float

The "type" is really the combination of the four, since we don't yet have a
mechanism like type classes, which could have rendered this as a single type:

    (Num a, Num b) => (x :: a): (y :: b): x + y

Going this route will require that we manage an implicit type classes
hierarchy, and perform unification on constraints as well as types. In the
interim, I just lifted the unification algorithm into the LogicT monad, and
use back-tracking search to find all the possible types an expression could
be.

The main problem with using LogicT, however, is that there are many types
it *couldn't* be, and in the case of a unification failure, it not yet clear
what the type should have been.  For example:

    "foo" + 2

Should the string have been a float or an integer or a path? Or should the
integer have been a string? So for now we report all the possibilities, since
it's not obvious which part of the expression is in error:

    hnix: Type error: TypeInferenceErrors
      [ UnificationFail (TCon "integer") (TCon "string")
      , UnificationFail (TCon "string") (TCon "path")
      , UnificationFail (TCon "string") (TCon "float")
      , UnificationFail (TCon "string") (TCon "integer")
      ]

This is a case where enumerating types rather than trying to make them compact
using type classes might actually be an improvement, since the errors here
would have been only slightly less numerous:

    string  != Num a => a
    string  != path
    integer != string

Clearly a better reporting mechanism is needed to clarify these problems. I
can imagine that in an IDE, there would be a squiggly under both sides of the
expression, each suggesting the type that was expected for that argument under
the assumption that the other argument (the one not be inspected) was the
correct one.
2018-05-01 20:49:10 -04:00
John Wiegley 9b02ad780f Pretty print type errors a little better (but more work needed) 2018-05-01 20:35:01 -04:00
John Wiegley f662d44c56 Hindley-Milner is close to working, just the MonadFix problem again 2018-04-30 21:52:25 -04:00
John Wiegley b8307d2fb5 Initial version of the attribute finder, still needs tweaking
```
hnix -I nix=$PWD/data/nix/corepkgs --find \
  --eval --expr "import $HOME/src/nix/nixpkgs {}" \
  -A pkgs.haskellPackages
```
2018-04-30 21:48:45 -04: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 ad0a53ed24 Fix two invalid function references 2018-04-27 21:00:45 -07:00
John Wiegley 0a21eb755c A minor naming change for consistency 2018-04-27 20:08:47 -07:00
John Wiegley 6c2149f767 Remove code TODOs, which have been changed into GitHub issues 2018-04-26 17:13:22 -07:00
John Wiegley defc5ed66d Add a new --values option for selectively displaying value provenance 2018-04-25 20:49:16 -07:00
John Wiegley 05ca87a732 Several improvements to error reporting; add new --thunks option 2018-04-25 13:00:41 -07:00
John Wiegley 2a61ed7307 Fix to value rendering (though won't work with scripting yet) 2018-04-25 00:03:17 -07:00
John Wiegley 2de8c7cf84 More fixes to error reporting 2018-04-24 12:25:40 -07:00
John Wiegley 01bcb86d3f Further improvements to error rendering, but not all done yet 2018-04-24 11:12:20 -07:00
John Wiegley 9864a8c7a5 Rework the way that info frames and error are handled
There is still work to be done to render the new "typed frames", and to
convert all the current string based frame into typed frames. This will pave
the way forward to smarter error messages that can be browsed in intelligent
environments like Emacs and the browser.
2018-04-24 02:15:28 -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