Commit Graph

57 Commits

Author SHA1 Message Date
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 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
Simon Jakobi 220209c090
Use neat-interpolation instead of interpolate (#635)
In addition to `interpolate`, this also removes the following
transitive dependencies:

 - `haskell-src-exts`
 - `haskell-src-meta`
 - `safe`
 - `th-expand-syns`
 - `th-lift`
 - `th-lift-instances`
 - `th-orphans`
 - `th-reify-many`

Since `neat-interpolation`'s `text` quasiquoter trims more whitespace
than `interpolate`'s `i`, the expected output of some tests for
`unsafeGetAttrPos` had to be updated.

This also improves the test failure output of the `constantEqual`
helper.

Fixes #634.
2020-06-27 10:43:50 +02:00
Silvan Mosberger 82b2d8af7f Use NSet for both recursive and non-recursive sets
Simplifies the AST
2019-07-25 14:10:44 -07:00
John Ericson f227911ce0 Merge remote-tracking branch 'origin/master' into prettyprinter 2018-11-20 18:23:15 -05:00
John Wiegley ba5b23a6e3
Bump minimum supported version to GHC 8.4.4 2018-11-19 09:46:02 -08:00
John Ericson 04abd357bd Switch to prettyprinter 2018-11-17 12:02:26 -05:00
John Wiegley 1af979e836
true and false shouldn't be in the reservedNames list
Fixes #343
2018-08-05 12:20:00 -04:00
John Wiegley 03efacd538
Add a commented out test for #343 2018-08-05 12:15:06 -04:00
John Wiegley 15baa5c8b8
Track attribute source positions in the binding, not the key name 2018-05-09 01:25:01 -07:00
John Wiegley 449d6611df
Remove the Uri type, it's just sugar
Fixes #308
2018-05-08 12:15:50 -07:00
Kaushik Chakraborty bbb72654d7
Parser: support tilde in paths 2018-04-21 11:47:57 +05:30
John Wiegley bb0e0d987c Slight improvements to the pretty printing output 2018-04-19 00:24:01 -07:00
John Wiegley 4163d35a09 nixpkgs allows let with no bindings in some places
At the beginning of arangodb/default.nix:

```
{ stdenv, fetchFromGitHub
, openssl, zlib, python2Packages, readline, cmake, python }:

let
in stdenv.mkDerivation rec {
  version = "3.3.4";
  name    = "arangodb-${version}";
```
2018-04-18 23:42:13 -07:00
John Wiegley a3c4bbfb76 Use NonEmpty for let bindings and attribute selector paths
Note that Nix allows inherit; and inherit (foo);, so we cannot make the list
of inherited names non-empty, even though the former constructions have no
meaning.
2018-04-17 12:46:41 -07:00
John Wiegley e6abbdc91e Add two more basic parsing tests 2018-04-12 14:22:55 -07:00
John Wiegley 978710aa7d Remember how much indentation was stripped from multi-line strings 2018-04-11 12:06:14 -07:00
John Wiegley a7e7e84795 Drop dependency on insert-ordered-containers
Fixes #161
2018-04-10 11:58:08 -07:00
John Wiegley 84f809a568 Add a test for issue #152 2018-04-10 11:22:54 -07:00
John Wiegley 9d7f25d368 All is building with Megaparsec now, but many parsing tests fail 2018-04-09 17:12:16 -07:00
John Wiegley 7df47c7d11 Implement builtins.unsafeGetAttrPos
Fixes #117
2018-04-05 23:16:55 -07:00
Doug Beardsley 42fbb1faa9 The eval-okay-xml test case passes
Still need to decide what to do with commented out instances
2018-04-05 17:06:00 -06:00
Ryan Trinkle 4992eaecbe Fix parsing of 4/2 (it should parse as a path) 2018-04-02 19:50:33 -04:00
John Wiegley 2e83606451 Simplify the definition of ParamSet 2018-04-01 20:56:57 -07:00
John Wiegley 852aff04e7 Break apart MonadNix, to allow greater flexibility in evaluators 2018-03-31 14:53:38 -07:00
John Wiegley 3a29249e43 Normalize import statements, add option parsing 2018-03-27 21:59:27 -07:00
Kosyrev Serge 0693768550
Fix #93: true/false being mis-parsed when part of an attribute name. 2018-03-06 04:14:16 +03:00
Guillaume Maudoux 0914047115 Handle `let { body = ... }` expressions 2018-02-10 13:30:33 +01:00
Rhys c15de4532a Correctly parse identifiers with reserved word prefixes 2017-04-17 19:33:57 +10:00
Allen Nelson 99b52fe48e separate expr into types and shorthands 2016-01-25 01:00:27 -06:00
Allen Nelson f04ccf9476 use KeyName list instead of AttrPath list 2016-01-24 18:01:45 -06:00
Allen Nelson 80a7dcb684 bump version, separate back out different kinds of params 2016-01-23 18:11:26 -06:00
Allen Nelson 29acdfe988 remove types for rec/nonrec, make unit tests pass 2016-01-23 17:32:45 -06:00
Allen Nelson 50a3d0d0db make tests pass 2016-01-23 15:51:34 -06:00
Allen Nelson d3a1e7207f split into more modules, rename some things, add docs 2016-01-23 15:23:18 -06:00
Allen Nelson 9765256ab4 parsing variadic functions, avoiding empty list error 2015-06-23 19:19:46 -05:00
Benno Fünfstück 1b82727a17 Use data-fix for Fix and fix path parsing bug 2014-09-27 20:12:30 +02:00
Benno Fünfstück c89db27dd9 Add some more tests for edge cases 2014-08-31 18:06:55 +02:00
Benno Fünfstück 94b7e4b1d7 tests for comment parsing and parser benchmarks 2014-08-27 23:54:31 +02:00
Benno Fünfstück 3a08227c0c Parse double unary - correctly and improve perf
We now don't use `buildExpressionParser` from parsers because it cannot
deal with double unary `-`, as in `--a`. Because nix doesn't have
operators which have the same precendence but different associativities,
we can greatly simplify the operator parser. This also has the effect of
improving performance and the error messages a bit.
2014-08-27 22:12:12 +02:00
Benno Fünfstück f3ec70192c parse // in paths correctly as update operator 2014-08-20 15:47:41 +02:00
Benno Fünfstück fe596a3e3a `1 + if true then 1 else 1` should also not parse
Operators are also not allowed to have an `if`, `let`, `with` or `assert`
expression as their argument (just like functions).
2014-08-19 19:20:17 +02:00
Benno Fünfstück 303fb9a3d7 Fix function application vs operator precedence
We now parse all of all-packages.nix! There are probably still
some parse bugs to catch, though.
2014-08-18 23:06:57 +02:00
Benno Fünfstück 8f0648f5bb Implement indented strings + uri + SPATH
We now parse till line 10005 of all-packages.nix
2014-08-18 22:54:20 +02:00
Benno Fünfstück bf77dde7fc `f if true then null else null` should not parse 2014-08-16 23:16:04 +02:00
Benno Fünfstück 87a83407a2 More tests for select expressions 2014-08-16 01:31:41 +02:00
Benno Fünfstück 24a4ffdce4 now really fix parsing paths 2014-08-16 01:17:01 +02:00
Benno Fünfstück 4a271d0103 fix error parsing paths 2014-08-16 00:18:16 +02:00
Benno Fünfstück bce48c438c parser: add tests and fix bugs 2014-08-15 23:30:24 +02:00
Benno Fünfstück a6bacc3150 antiquotes + improve pretty printer + restructure
This commit improves the pretty printing and adds support for
antiquotes. It also fixes an issue with the parser that caused `[if true
then false else true]` to parse successfully, even though that is not a
valid nix expression.

The pretty printer now produces a lot more readable output and also
supports operator precedences.

The changes to the AST are:

  * strings are no longer atomic, because they may contain other
  expressions in the form of antiquotes. For strings, the new type
  NString is introduced and the constructor NStr is added to NExprF
  * the unused NVar constructor of NExprF is removed
  * operators are now represented uniformly so that the pretty printer
  can lookup information about operators (in particular, associativity
  and precedence)
  * the NArgs constructor is removed. The first argument of the NAbs
  constructor now directly represents the lambda arguments.
  * the select and the hasattr operator are moved into NExpr because
  they are special (they only accept a selector as second argument, and
  select also supports 'or')

The list of operators is now in Types.hs and Parser.hs re-uses that list
to build the parser. This is required because the pretty printer and
parser both need access to operator precedences.

Parser and evaluator also support dynamic attributes and attributes with
dots now. As an example, `let b.a = 3; b.c = { e = {}; }; b.c.e.${"f"} =
4; in b` is parsed and evaluated correctly. As a side effect, NSym
values now don't evaluate to themselves anymore, but instead to the
value retrieved by looking up the variable in the current environment.

Support for evaluating `inherit` bindings was removed because it was
broken before (`{ inherit a; }` would evaluate to a set where the
attribute `a` had the value `NSym a`, not the value of `a`).

The manual Show instances for the AST were replaced by derived
ones, because the manual instances often resulted in output were it was
difficult to determine the missing parentheses.
2014-08-15 22:11:54 +02:00