Commit Graph

44 Commits

Author SHA1 Message Date
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
Simon Jakobi 54030284fa Update to data-fix-0.3
Changelog: http://hackage.haskell.org/package/data-fix-0.3.0/changelog

Context: https://github.com/commercialhaskell/stackage/issues/5535
2020-07-24 12:35:59 +03:00
Simon Jakobi f0532b86f6
Silence redundant import warnings for Control.Monad.Fail (#633)
Also address mysterious redundant import warnings in the testsuite

This allows us to enable `buildStrictly=true` for GHC 8.8.

Fixes #613.
2020-06-19 02:21:06 +02:00
Anton-Latukha 8ebb26f371
src/Nix/Type/Infer.hs: clean-up imports
M  src/Nix/Type/Infer.hs
2020-06-03 02:37:39 +03:00
Silvan Mosberger f682907c97 Make URI's be separate from strings 2020-05-15 17:49:11 -07:00
Linus Heckemann 600fdb93e8 types: fix type of concat binop
Nix's ++ does not in fact allow concatting null with a list:

nix-repl> [] ++ null
error: value is null while a list was expected, at (string):1:1

nix-repl> null ++ []
error: value is null while a list was expected, at (string):1:1
2019-06-25 20:23:50 +02:00
John Wiegley 4607639774 Remove the NValueNF type, as it provides little utility 2019-03-27 21:16:01 -07:00
John Wiegley 77c52fd43c Revise Nix.Standard 2019-03-23 00:49:03 -07:00
John Wiegley 47143fda73
Add an 'inform' method to MonadValue 2019-03-19 13:10:35 -07:00
John Wiegley d1ada44817
Run brittany 2019-03-18 21:47:43 -07:00
John Wiegley 439ae6ce0d
More work toward harmonization; now down to porting Builtins 2019-03-18 14:01:48 -07:00
John Wiegley 94e0be3882
Reformat all sources with Brittany, to restore consistency 2019-03-17 14:47:38 -07:00
John Wiegley 492a3ae0bc
Factor out thunk id representation into its own class, MonadThunkId 2019-03-16 16:23:40 -07:00
John Wiegley 537f1fc8c7
Finish out the instance definitions in Standard.hs 2019-03-16 12:48:07 -07:00
John Wiegley ace0fc10d5
Further progress 2019-03-14 15:10:41 -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
Madeline Haraj 28ab983408
Add syntactic holes 2019-03-10 10:23:28 -07:00
John Wiegley eae6bf542f Split MonadFreshId off into its own file 2019-03-10 08:58:27 -07:00
Ken Micklas 695dd58d3c Fix failable pattern in fresh 2019-03-09 21:40:59 -05:00
Ken Micklas d9293cf034 Fix Nix.Exec 2019-03-09 20:26:19 -05:00
Ken Micklas 3b4af6f781 Move MonadAtomicRef ST instance to Nix.Thunk 2019-03-09 20:26:19 -05:00
Ken Micklas ae09c47b7d Fix Nix.Type.Infer 2019-03-09 20:26:19 -05:00
Ken Micklas 69fa8884c1 Add MonadAtomicRef instance for ST 2019-03-09 20:26:19 -05:00
John Ericson 1abe4064c6 WIP more instances 2019-03-09 20:26:19 -05:00
John Ericson 3b5649c0a2 WIP fix equality 2019-03-09 20:26:19 -05:00
Domen Kožar 58a83622eb
GHC 8.6 support 2018-11-20 23:44:59 +00:00
John Wiegley ba5b23a6e3
Bump minimum supported version to GHC 8.4.4 2018-11-19 09:46:02 -08:00
Ryan Trinkle d60130c566 Abstract Scopes 2018-11-17 16:21:03 -05:00
Ryan Trinkle 6d2daf0ecd WIP: Refactor MonadVar to use ref-tf's MonadRef instead
TODO:
* Upstream GEq (STRef s)
* Eliminate shim functions
2018-11-16 14:11:37 -05:00
gb 4baa4f7108 change Nix.NixString module to Nix.String 2018-09-23 16:03:44 -04:00
gb 2fadbe3090 add new nixstring version with warnings 2018-09-09 11:01:09 -04:00
gb ea3b675f28 update fork from master 2018-07-28 13:23:23 -04:00
John Wiegley 9617c90a9e
Change the name of TArr to :~> 2018-05-17 22:16:50 -07:00
gb 43c145252d NixString is in its own module hiding the constructors 2018-05-08 16:47:50 -04:00
John Wiegley 449d6611df
Remove the Uri type, it's just sugar
Fixes #308
2018-05-08 12:15:50 -07:00
gb 8e7d9d32fa add string context 2018-05-03 08:07:54 -04:00
John Wiegley fe4629c3a4 More fixes to type inference 2018-05-02 15:08:53 -07:00
John Wiegley 18fc312112 Further corrections to type checking functions that take sets 2018-05-02 13:46:32 -07:00
John Wiegley 8538859230 Work on type inference for functions that take attr sets 2018-05-01 21:50:50 -04:00
John Wiegley 49e71222c3 Instead of EqConstOneOf, use TMany which is more fundamental
This allows both multiple function types, or a function that might return one
of many possible values, for example.
2018-05-01 21:04:10 -04: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 caf0a4a6a2 Add support for building with GHC 8.4.1, also on Travis 2018-04-23 16:39:37 -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