hnix/hnix.cabal

242 lines
4.6 KiB
Plaintext
Raw Normal View History

2018-04-08 00:08:48 +02:00
-- This file has been generated from package.yaml by hpack version 0.27.0.
--
-- see: https://github.com/sol/hpack
--
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-02 02:35:13 +02:00
-- hash: 495fbcc0ec91c76bd2a6f9a571bca3014f7dd68489dc137eb17528a4dfde7a00
2018-04-08 00:08:48 +02:00
name: hnix
version: 0.5.0
synopsis: Haskell implementation of the Nix language
description: Haskell implementation of the Nix language.
category: System, Data, Nix
homepage: https://github.com/jwiegley/hnix#readme
bug-reports: https://github.com/jwiegley/hnix/issues
author: John Wiegley
maintainer: johnw@newartisans.com
license: BSD3
license-file: LICENSE
build-type: Simple
cabal-version: >= 1.10
2018-04-08 00:08:48 +02:00
extra-source-files:
README.md
2015-07-23 04:03:30 +02:00
2018-04-08 00:08:48 +02:00
source-repository head
type: git
location: https://github.com/jwiegley/hnix
flag optimize
description: Enable all optimization flags
manual: True
default: False
flag profiling
description: Enable profiling
manual: True
default: False
flag tracing
description: Enable full debug tracing
manual: True
default: False
2018-04-08 00:08:48 +02:00
library
exposed-modules:
Nix
Nix.Atoms
Nix.Builtins
Nix.Cache
Nix.Context
Nix.Convert
Nix.Effects
2018-04-08 00:08:48 +02:00
Nix.Eval
2018-04-09 09:52:10 +02:00
Nix.Exec
2018-04-08 00:08:48 +02:00
Nix.Expr
Nix.Expr.Shorthands
Nix.Expr.Types
Nix.Expr.Types.Annotated
Nix.Frames
2018-04-08 00:08:48 +02:00
Nix.Lint
Nix.Normal
Nix.Options
2018-04-08 00:08:48 +02:00
Nix.Parser
Nix.Parser.Library
Nix.Parser.Operators
Nix.Pretty
Nix.Reduce
Nix.Render
Nix.Render.Frame
2018-04-08 00:08:48 +02:00
Nix.Scope
Nix.Strings
2018-04-08 00:08:48 +02:00
Nix.TH
Nix.Thunk
Nix.Type.Assumption
Nix.Type.Env
Nix.Type.Infer
Nix.Type.Type
2018-04-08 00:08:48 +02:00
Nix.Utils
Nix.Value
Nix.XML
other-modules:
Paths_hnix
hs-source-dirs:
src
2018-04-29 03:21:24 +02:00
ghc-options: -Wall
2018-04-08 00:08:48 +02:00
build-depends:
aeson
, ansi-wl-pprint
2018-04-08 00:08:48 +02:00
, array >=0.4 && <0.6
, base >=4.9 && <5
2018-04-02 03:20:53 +02:00
, base16-bytestring
2018-04-11 03:57:17 +02:00
, binary
2018-04-08 00:08:48 +02:00
, bytestring
, compact
, containers
2018-04-02 03:20:53 +02:00
, cryptohash
, data-fix
, deepseq
2018-04-08 00:08:48 +02:00
, deriving-compat >=0.3 && <0.5
, directory
2018-04-08 00:08:48 +02:00
, exceptions
, filepath
, hashable
, haskeline
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-02 02:35:13 +02:00
, logict
, megaparsec
2018-04-08 00:08:48 +02:00
, monadlist
, mtl
, optparse-applicative
, pretty-show
2018-04-08 00:08:48 +02:00
, process
, regex-tdfa
, regex-tdfa-text
, scientific
2018-04-08 00:08:48 +02:00
, semigroups >=0.18 && <0.19
, serialise
, split
2018-04-08 00:08:48 +02:00
, syb
, template-haskell
2018-04-08 00:08:48 +02:00
, text
2018-03-28 03:42:31 +02:00
, these
2018-04-08 00:08:48 +02:00
, transformers
2018-04-02 04:16:55 +02:00
, unix
2018-04-08 00:08:48 +02:00
, unordered-containers >=0.2.9 && <0.3
, vector
, xml
if flag(tracing)
cpp-options: -DENABLE_TRACING=1
if impl(ghc < 8.4.0) && !flag(profiling)
build-depends:
ghc-datasize
2018-04-08 00:08:48 +02:00
default-language: Haskell2010
2018-04-08 00:08:48 +02:00
executable hnix
main-is: Main.hs
other-modules:
Repl
2018-04-08 00:08:48 +02:00
Paths_hnix
hs-source-dirs:
main
2018-04-29 03:21:24 +02:00
ghc-options: -Wall
2018-04-08 00:08:48 +02:00
build-depends:
aeson
, ansi-wl-pprint
2018-04-08 00:08:48 +02:00
, base >=4.9 && <5
, bytestring
, compact
, containers
, data-fix
, deepseq
2018-04-08 00:08:48 +02:00
, exceptions
, filepath
, haskeline
2018-04-08 00:08:48 +02:00
, hnix
, mtl
, optparse-applicative
, pretty-show
, repline
, serialise
, template-haskell
2018-04-08 00:08:48 +02:00
, text
, transformers
2018-04-08 00:08:48 +02:00
, unordered-containers >=0.2.9 && <0.3
if flag(tracing)
cpp-options: -DENABLE_TRACING=1
2018-04-08 00:08:48 +02:00
default-language: Haskell2010
2018-04-08 00:08:48 +02:00
test-suite hnix-tests
type: exitcode-stdio-1.0
main-is: Main.hs
other-modules:
EvalTests
NixLanguageTests
ParserTests
PrettyTests
2018-04-08 00:13:58 +02:00
TestCommon
2018-04-08 00:08:48 +02:00
Paths_hnix
hs-source-dirs:
tests
2018-04-29 03:21:24 +02:00
ghc-options: -Wall -threaded
2018-04-08 00:08:48 +02:00
build-depends:
Glob
, ansi-wl-pprint
, base >=4.9 && <5
, bytestring
, compact
2014-08-03 14:17:43 +02:00
, containers
, data-fix
, deepseq
2018-04-10 21:38:14 +02:00
, directory
2018-04-08 00:08:48 +02:00
, exceptions
, filepath
2018-04-08 00:08:48 +02:00
, hnix
, interpolate
, mtl
, optparse-applicative
, process
, serialise
, split
2018-04-08 00:08:48 +02:00
, tasty
, tasty-hunit
, tasty-th
, template-haskell
, text
, transformers
, unix
2018-04-08 00:08:48 +02:00
, unordered-containers >=0.2.9 && <0.3
if flag(tracing)
cpp-options: -DENABLE_TRACING=1
2018-04-08 00:08:48 +02:00
default-language: Haskell2010
2014-08-03 14:17:43 +02:00
2018-04-08 00:08:48 +02:00
benchmark hnix-benchmarks
type: exitcode-stdio-1.0
main-is: Main.hs
other-modules:
ParserBench
Paths_hnix
hs-source-dirs:
benchmarks
2018-04-29 03:21:24 +02:00
ghc-options: -Wall
2018-04-08 00:08:48 +02:00
build-depends:
ansi-wl-pprint
, base >=4.9 && <5
, bytestring
, compact
, containers
, criterion
2018-04-08 00:08:48 +02:00
, data-fix
, deepseq
2018-04-08 00:08:48 +02:00
, exceptions
, filepath
2018-04-08 00:08:48 +02:00
, hnix
, mtl
, optparse-applicative
, serialise
2018-04-08 00:08:48 +02:00
, template-haskell
, text
, transformers
, unordered-containers >=0.2.9 && <0.3
if flag(tracing)
cpp-options: -DENABLE_TRACING=1
2018-04-08 00:08:48 +02:00
default-language: Haskell2010