Commit Graph

239 Commits

Author SHA1 Message Date
John Wiegley 471712f11f
Switch PrettyPrintTests from QuickCheck to Hedgehog
The reason being that we get better shrinking by default, and no orphan
instances.
2018-05-14 21:22:04 -07:00
John Wiegley eef2ec2512
Only use compact with GHC 8.2, as per the documentation for compact 2018-05-10 16:12:42 -07:00
John Wiegley 892ce63e1a
Don't guard compact based on the version 2018-05-10 15:35:31 -07:00
John Wiegley 865984b428
Permit building with GHC 8.0, extend the Travis build matrix 2018-05-10 15:07:32 -07:00
John Wiegley 14138bfc97
Update GitHub link to point to haskell-nix 2018-05-10 13:57:53 -07:00
John Wiegley dbd8468862
In Builtins.hs, just include derivation.nix directly 2018-05-10 13:51:14 -07:00
John Wiegley addea54208
Add more missing files 2018-05-09 10:59:08 -07:00
John Wiegley f5155a12dd
Add files missing from Hackage tarball, bump to 0.5.1 2018-05-09 10:43:25 -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 ce3b0d70e9
Move all of the parsing code into a single module, for optimization 2018-05-07 12:06:56 -07:00
John Wiegley 2457efdaa3
Only invoke pretty/parser tests if PRETTY_TESTS=<N> for some N>0 2018-05-06 22:13:30 -07:00
John Wiegley 1895cff9cc Update hnix.cabal 2018-05-06 10:43:51 -07:00
John Wiegley e7a6456a35 Make use of lens-family to provide some utility lenses/traversals 2018-05-06 10:43:43 -07:00
Matthew Pickering b0ed29b3df Add QuickCheck test for pretty printer and parser
I have not spent any time optimising the generated programs but they do
not look totally unreasonable from a cursory inspection.

Fixes #158
2018-05-06 10:31:52 +00:00
John Wiegley a627d885e8 Implement builtins.fetchurl
Squashed commit of the following:

commit 15b10d898e0457237f07cda9e5e9525bac0e95f6
Author: John Wiegley <johnw@newartisans.com>
Date:   Wed May 2 16:33:30 2018 -0700

    Update Exec.hs

commit d4a886dccf2715f1c1790e01adc242c352e7f427
Merge: 02afb27 4caacc1
Author: John Wiegley <johnw@newartisans.com>
Date:   Wed May 2 16:08:55 2018 -0700

    Merge branch 'master' into http

commit 02afb275f2078c1184a901da3ea0262630fefeea
Author: John Wiegley <johnw@newartisans.com>
Date:   Wed May 2 16:08:42 2018 -0700

    Update Exec.hs

commit 3733ce5888adb7161d2f57a16204ab953e9c4d7d
Author: John Wiegley <johnw@newartisans.com>
Date:   Wed May 2 16:07:08 2018 -0700

    Update Builtins.hs

commit 4402be6d04ac34156d50f8ee29f9af300de75ce5
Merge: 2c60097 13f3ebd
Author: John Wiegley <johnw@newartisans.com>
Date:   Wed May 2 15:06:28 2018 -0700

    Merge branch 'master' into http

commit 2c600976bb3a5d9267a0f313487dd0ab1a6ce1f7
Merge: 4a9d1a5 555ce95
Author: John Wiegley <johnw@newartisans.com>
Date:   Wed May 2 14:25:59 2018 -0700

    Merge branch 'master' into http

commit 4a9d1a56d463567ad155a58fc39f5b24e2636120
Merge: 4dd46f2 431006f
Author: John Wiegley <johnw@newartisans.com>
Date:   Wed May 2 14:20:57 2018 -0700

    Merge branch 'master' into http

commit 4dd46f21e3f594c4f7ae5bee8412a7841e566d4c
Author: Ian-Woo Kim <ianwookim@gmail.com>
Date:   Sun Apr 29 12:51:11 2018 -0700

    generated hnix.cabal

commit c87ae993fb7dbb1117f03133862799e1549c4259
Author: Ian-Woo Kim <ianwookim@gmail.com>
Date:   Sat Apr 28 16:55:11 2018 -0700

    remove dep from hnix.cabal

commit 0bb8856c8759ad3c67a0b4eb1d26b6195da82667
Author: Ian-Woo Kim <ianwookim@gmail.com>
Date:   Sat Apr 28 16:53:54 2018 -0700

    remove http-client stuff from default.nix

commit d298756a2ba4376f8cb3c54fb723a00697e0821d
Author: Ian-Woo Kim <ianwookim@gmail.com>
Date:   Sat Apr 28 15:49:59 2018 -0700

    getURL is implemented for both http and https

commit a3d66c07a097aedb03f30bcc636fcb3d5717e1fe
Merge: c4cb48a a73eae5
Author: Ian-Woo Kim <ianwookim@gmail.com>
Date:   Sat Apr 28 15:14:32 2018 -0700

    Merge branch 'builtin2' into http

commit c4cb48a8a756e82fb7d389ff501b2a85001dba38
Author: Ian-Woo Kim <ianwookim@gmail.com>
Date:   Sat Apr 28 15:13:25 2018 -0700

    add getURL function

commit ff23fc18ed16075353a58725d7d08f41605a6070
Author: Ian-Woo Kim <ianwookim@gmail.com>
Date:   Sat Apr 28 15:06:40 2018 -0700

    use http-client-* instead of HTTP

commit fcbe40f3bea84607a9d7849a9f3d2fc3a6cb9bef
Author: Ian-Woo Kim <ianwookim@gmail.com>
Date:   Sat Apr 28 14:58:07 2018 -0700

    add HTTP

commit a73eae573a193dbb8361e03b584a6cd55e7c427a
Author: Ian-Woo Kim <ianwookim@gmail.com>
Date:   Sat Apr 28 14:36:24 2018 -0700

    implement fetchurl (as a copy of fetchTarball)
2018-05-02 21:38:39 -07:00
hsloan c1561ea711 Implement builtins.currentTime 2018-05-02 21:32:00 -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 f662d44c56 Hindley-Milner is close to working, just the MonadFix problem again 2018-04-30 21:52:25 -04:00
John Wiegley bda103bc11 Don't include ghc-datasize if --flags=profiling is set 2018-04-30 21:48:45 -04:00
John Wiegley 7f01cc8bb8 valueSize will not work with GHC 8.4 right now
ghc-heap-view hasn't been updated yet
2018-04-28 18:29:37 -07:00
John Wiegley 8d0a67b52c Only turn on -Werror for Travis 2018-04-28 18:21:24 -07:00
John Wiegley b24598b3a3 Add top-level __valueSize
Fixes #253
2018-04-28 17:12:32 -07:00
John Wiegley ad18b950ac Turn warnings into errors 2018-04-28 16:26:32 -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 05ca87a732 Several improvements to error reporting; add new --thunks option 2018-04-25 13:00:41 -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 a60181df3a Add --flags=optimize for cabal configure 2018-04-22 14:33:38 -07:00
John Wiegley 96a0c387dd Merge Nix.Trace and Nix.Reduce into Nix.Reduce
Since almost all of that code had to do with program reduction. addTracing and
tracingEvalExpr have moved into Exec.hs, since they depend on MonadNix.
2018-04-21 10:28:09 -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 47e8829a28 Rename Nix.StringOperations to Nix.Strings 2018-04-20 17:05:21 -07:00
John Wiegley 986a3043da Add a constant-folding tree transformer: Reduce.reduceExpr 2018-04-20 02:57:23 -07:00
John Wiegley 0ff6c7a1e4 Move tracing code into its own file 2018-04-18 21:43:18 -07:00
John Wiegley 92217059b5 Add --flags=tracing, and document it in README.md 2018-04-18 16:28:21 -07:00
John Wiegley 8d25aa461d Add --json option to hnix, which can render both expressions and values 2018-04-17 14:24:52 -07:00
John Wiegley f4fbbe7903 Make NKeyName and NString instances of Hashable 2018-04-17 11:33:20 -07:00
John Wiegley 6c9cbf241a Rewrite ToNix/FromNix, although Builtins.hs is not using it yet 2018-04-13 18:09:12 -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
John Wiegley 96df58fb29 Split off command-line options processing into a new Nix.Options module 2018-04-11 20:53:38 -07:00
John Wiegley b621ffee0a Move the caching support code into its own Nix.Cache module 2018-04-11 20:21:02 -07:00
John Wiegley 22175aa927 Use the serialise library on non-Linux systems, compact on Linux 2018-04-11 17:59:42 -07:00
John Wiegley 941d4f9fd3 Add testing code for writing out Nix parses as compact regions 2018-04-11 14:35:17 -07:00
John Wiegley cd4aa33abd Run the tests with threading enabled, for parallel execution 2018-04-11 13:53:55 -07:00
John Wiegley 74de14dc7d Restore the linter, to some degree, at least for the language tests 2018-04-10 21:02:01 -07:00
John Wiegley 5efa46e516 Add Binary instances for NExpr 2018-04-10 18:57:17 -07:00
John Wiegley dcd081d899 Add directory dependency for the tests 2018-04-10 12:38:14 -07:00
John Wiegley a7e7e84795 Drop dependency on insert-ordered-containers
Fixes #161
2018-04-10 11:58:08 -07:00
John Wiegley 81c63a98d5 Comment out -fexpose-all-unfoldings while profiling 2018-04-10 09:02:59 -07:00
John Wiegley 8f37f37986 Down to 16 basic test failures with megaparsec 2018-04-09 21:35:46 -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 b1fb73d363 Remove Trifecta and parsec, begin switch to megaparsec 2018-04-09 10:16:25 -07:00
John Wiegley 4c2eebbe40 Refactor evaluation using a type class 2018-04-09 00:52:10 -07:00
John Wiegley 3681d51dd6 Create modules Nix.Monad.Lazy, Nix.Monad.Lint, Nix.Monad.Context 2018-04-07 23:14:08 -07:00
John Wiegley 9dcd7b37b6 Factor some code into new module Nix.Normal 2018-04-07 15:25:39 -07:00
John Wiegley c8e9012778 Some minor fixups for compilation 2018-04-07 15:13:58 -07:00
John Wiegley deb592b11d Undo changes to hnix.cabal 2018-04-07 15:08:48 -07:00
Doug Beardsley 1b7dac071d Test to catch a bug in builtins.match
Also added infrastructure for comparing against current nix behavior,
not just current nix tests.
2018-04-07 15:07:09 -07:00
John Wiegley ea6a98f602 Implement builtins.tryEval 2018-04-07 14:33:15 -07:00
John Wiegley 935c7c5ee1 Remove some unnecessary code from package.yaml 2018-04-07 14:17:17 -07:00
John Wiegley 954ffccebb Ensure in the tests that hnix.cabal is not edited directly 2018-04-07 12:09:49 -07:00
John Wiegley 443129315d Use hpack and move all the Nix sources into a src/ directory 2018-04-07 12:02:33 -07:00
John Wiegley d9047cc216 Factor out some code into new module Nix.Value 2018-04-07 11:38:12 -07:00
Doug Beardsley 002a7ad1b9 Replace pcre-light with regex-tdfa
The regex-tdfa package implements POSIX extended regular expressions,
which are what Nix uses.
2018-04-06 11:46:56 -06:00
John Wiegley 1a01f85de9 Implement builtins.match, and add a dependency on pcre-light 2018-04-05 23:50:32 -07:00
John Wiegley 9d5a7f8a27 Remove some settings from hnix.cabal 2018-04-05 21:10:06 -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
John Wiegley 51b55f3e2d Pin insert-ordered-containers to a custom version 2018-04-05 13:23:22 -07:00
John Wiegley 1363d20f18 Bump working version to 0.5.0 2018-04-05 13:23:14 -07:00
John Wiegley d476b3f173 Add a toXML serializer for values
Relates to issue #109
2018-04-05 01:13:13 -07:00
Ryan Trinkle 3c339340c6 Add builtins.fromJSON and builtins.toJSON 2018-04-03 20:37:38 -04:00
John Wiegley c3eb7a94b9 Add basic support for quasi-quotation of Nix expressions in Haskell 2018-04-03 14:21:33 -07:00
John Wiegley ffb97610db Generalize the thunking mechanism, so it can be used over Symbolics 2018-04-01 23:48:07 -07:00
John Wiegley d7228c6a75 Move language feature pragmas into each Haskell file, not .cabal 2018-04-01 22:49:12 -07:00
Ryan Trinkle 5fc350cef0 Add builtins.readDir 2018-04-01 22:16:55 -04:00
Ryan Trinkle fb1616053d Add builtins.hashString 2018-04-01 21:20:53 -04:00
Ryan Trinkle 81aec9dfd0 Merge branch 'master' of github.com:jwiegley/hnix
# Conflicts:
#	Nix/Builtins.hs
#	Nix/Eval.hs
2018-04-01 14:35:06 -04:00
Ryan Trinkle a1a3c81211 Add builtins.sort 2018-04-01 14:16:47 -04:00
John Wiegley f47b764dcf Initial phase of sym eval completed, still missing function application 2018-04-01 10:34:08 -07:00
Ryan Trinkle 3e3e61acd9 Add more path normalization to do it the way Nix does 2018-03-31 19:53:35 -04:00
Ryan Trinkle 6acdfb061c Add version bounds for unordered-containers
We use the Ord instance for HashMap, which was created in unordered-containers-0.2.9.0
2018-03-31 18:46:42 -04:00
John Wiegley 852aff04e7 Break apart MonadNix, to allow greater flexibility in evaluators 2018-03-31 14:53:38 -07:00
John Wiegley d08ca26da0 Add informative backtraces on evaluation failure 2018-03-30 23:10:44 -07:00
John Wiegley 4e29e6453f Don't use -threaded in hnix.cabal at the moment 2018-03-30 23:10:44 -07:00
John Wiegley 9f6c2ba948 Move a lot of code around into new modules 2018-03-30 14:08:38 -07:00
John Wiegley 5effdda04b Move the scoping code into its own module 2018-03-30 13:30:28 -07:00
John Wiegley a4a2fc0659 Move the linting code into its own module 2018-03-30 12:45:23 -07:00
John Wiegley 71b4bf5e8a Various fixes, and make imports local to their containing file 2018-03-30 01:50:19 -07:00
Ryan Trinkle 3f29f65477 Use nix-store --add to convert paths to strings
Fixes eval-fail-bad-antiquote-2
2018-03-29 20:23:22 -04:00
John Wiegley 84918aa1d3 Remove the MonadFix requirement, it was not needed; fix NRecSet 2018-03-28 23:52:07 -07:00
John Wiegley 39f772ef3c Restore monadic abstraction (to support importFile), fix attribute sets 2018-03-28 14:45:10 -07:00
John Wiegley b923af49f4 Split off some utility functions into their own Nix.Utils module 2018-03-27 22:32:43 -07:00
John Wiegley 3a29249e43 Normalize import statements, add option parsing 2018-03-27 21:59:27 -07:00
John Wiegley 278916a9ab Further work on argument evaluation 2018-03-27 18:42:31 -07:00
David Johnson 37e457367b
Bump deriving-compat upper bound 2018-03-27 12:34:56 -07:00
Allen Nelson e6be5e0096 rm mention of shorthandtests from cabal file 2018-02-28 11:34:50 -06:00
Guillaume Maudoux 25f1da3408 Run lang tests from upstream 2018-02-15 12:06:09 +01:00
Guillaume Maudoux 5718952e7b Add NValue constructors for builtins 2018-02-15 12:05:23 +01:00
John Wiegley d3f9302c9f Bump Cabal version to 0.4 2018-01-22 12:13:30 -08:00
Rhys 0d456691b5 Escape ${ but not plain $ in indented strings
Includes some very basic regression tests, but no change for
non-indented strings.
2017-05-31 21:24:43 +10:00
Rhys 6537b8823d Add ShorthandTests to .cabal file 2017-05-31 21:07:19 +10:00
Profpatsch 8b4c137a3b Shorthands.hs, mkDot/mkDots: automatically quote non-symbols
Nix can accept (nearly?) arbitrary values as attributes, if they are quoted in
strings. So generating “dots” should always result in valid nix attributes.
This uses the same regex as the nix lexer (as of 1.11).

Also add a few tests whether it correctly generates symbol/non-symbol
attributes.
2017-04-21 03:54:06 +02:00
Rickard Nilsson 386c472cc7 Bump to 0.3.4 2016-10-20 22:04:00 +02:00
John Wiegley 3a23917d59
Mention EvalTests.hs in hnix.cabal 2016-10-17 16:59:52 -07:00
John Wiegley 2f06b934ef
Bump to 0.3.3 2016-10-03 20:10:35 -07:00
Joe Hermaszewski d3651984fb Add Show1 instances for base 4.9 2016-09-21 10:32:17 +01:00
Joe Hermaszewski a19a943f9b Derive foldable and traversable for more types 2016-06-29 00:10:09 +01:00
Joe Hermaszewski 0f180164e5 Bump version, slight changes to project.nix 2016-06-25 16:14:19 +01:00
Joe Hermaszewski 5f3903caeb Add Nix.Expr.Types.Annotated to cabal file 2016-06-25 11:38:31 +01:00
Joe Hermaszewski c11aad7253 Implement Annotation support functions 2016-06-25 11:17:18 +01:00
Allen Nelson 99b52fe48e separate expr into types and shorthands 2016-01-25 01:00:27 -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 a876d49789 parseNixText function 2015-10-27 17:32:03 -05:00
Allen Nelson 892cad2b36 Correctly escape double quotes. Update nix files. Use quotes with reserved variable bindings 2015-10-15 18:38:06 -05:00
John Wiegley c8173f0abd Add Extra-source-files 2015-07-22 19:03:30 -07:00
John Wiegley d678cf9cff Add data/* as Extra-source-files 2015-07-20 14:00:24 -07:00
Adam Bergmark 703f2628e1 Needs GHC >= 7.6 due to MultiWayIf, LambdaCase, DataKinds 2015-06-28 02:13:08 +02:00
Allen Nelson b4c66b4876 not evaluating in hnix executable, only parsing 2015-06-23 16:53:07 -05:00
John Wiegley 04f210c47e Bump version to 0.2.0 2015-06-23 16:50:03 -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 323f51f97b Rename benchmarks to hnix-benchmarks, like tests 2014-08-28 00:02:56 +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 82c19b650c Add Pretty to cabal file and remove Internal 2014-08-19 18:51:13 +02:00
Benno Fünfstück 3413a817e6 subdirectory for main to avoid redundant compile
Cabal builds the library files twice if the main executable and the
library share the same hs-source-dirs. Moving the main executable source
code to a subdirectory avoids this issue.
2014-08-19 18:48:55 +02:00
Benno Fünfstück 1b85b76a4e parsec: Also use parsers (like trifecta)
This saves a lot of duplication and also makes it easier
to keep the parsec and trifecta versions of the parser in sync.
2014-08-15 16:11:05 +02:00
Benno Fünfstück ac9675baae More tests (one currently failing) and fixes 2014-08-05 21:23:28 +02:00
Benno Fünfstück 19c77ae2d1 trifecta: don't allow reserved in identifier
trifecta should not parse reserved words as identifiers. Before
this commit, `in` would parse as an identifier name and thus
`let a = b; in c` fails to parse.
2014-08-03 16:16:52 +02:00
Benno Fünfstück 3922112bab add a few hunit tests for parser 2014-08-03 15:56:01 +02:00
John Wiegley 92cf6eecf9 Switch from pretty to ansi-wl-pprint 2014-07-18 04:42:06 -05:00
Luca Bruno b12dc4f187 Pretty print nix expressions 2014-07-07 16:26:14 +02:00
John Wiegley be1434726a Add initial support for parsing operators 2014-07-01 01:12:28 -05:00
John Wiegley 8158557bb9 Factor out the abstract of which parsing library to use 2014-06-30 23:29:06 -05:00
John Wiegley 9b12ebf081 Break up Parser.hs, make use of Parsec optional 2014-06-30 23:12:18 -05:00
John Wiegley 29909a2598 Setup cabal file, fix all warnings
The next step is splitting up and prettifying Parser.hs
2014-06-30 22:37:20 -05:00