-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display multiple example types for things with nontrivial (non-parame…
…tric) polymorphism (#388) Closes #169. Previously, we did this: ``` Disco> :type \x. x - 2 λx. x - 2 : ℤ → ℤ ``` However, this was a lie since in fact `\x. x - 2` is more general than that; but showing only one possible monomorphic type was still better than showing some generic monstrosity like `forall a. (N <: a, subtractive a) => a -> a`. Now, with this PR, we do this: ``` Disco> :type \x. x - 2 This expression has multiple possible types. Some examples: λx. x - 2 : ℤ → ℤ λx. x - 2 : ℚ → ℚ ``` See #169 for more context and examples. Briefly, in this PR, we: - Change the solver to return a *list* of solution substitutions instead of just a single one - Add a "solution limit" counter to the solver so it can stop early once it has hit the limit for the number of solutions we want. - In some cases (e.g. when checking a provided type) we just want one. - In other cases (when inferring a type) we set an arbitrary bound of 16. - This is not really ideal --- in theory we would want to use some kind of proper backtracking logic monad like `LogicT` but that seems difficult/impossible to incorporate into `polysemy` (https://stackoverflow.com/questions/62627695/running-the-nondet-effect-once-in-polysemy; polysemy-research/polysemy#246). - "Thin" the resulting list of solutions by throwing away any solutions which are supertypes of another solution in the list. - Add pretty-printing that distinguishes between a single solution and multiple solutions It is still possible to make the solver blow up in case there are many possible container variables to instantiate. *e.g.* expressions like `\x. \y. \z. \w. (set(x), set(y), set(z), set(w))` take a very long time to typecheck. I have some ideas for how to improve this situation, but for now it's an uncommon corner case.
- Loading branch information
Showing
27 changed files
with
545 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
#!/bin/sh | ||
stack test --fast --file-watch --test-arguments '--hide-successes +RTS -N8 -RTS' | ||
cabal test -j -O0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
loops: | ||
test8: stack test --fast --test-arguments '--hide-successes +RTS -N8 -RTS' | ||
test30: stack test --fast --test-arguments '--hide-successes +RTS -N30 -RTS' | ||
build: cabal -j build -O0 | ||
test: cabal -j test -O0 --test-show-details=direct |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,2 @@ | ||
cradle: | ||
multi: | ||
- path: "./explore" | ||
config: | ||
cradle: | ||
none: | ||
- path: "./nsf" | ||
config: | ||
cradle: | ||
none: | ||
- path: "./pubs" | ||
config: | ||
cradle: | ||
none: | ||
- path: "./notes" | ||
config: | ||
cradle: | ||
none: | ||
- path: "./example" | ||
config: | ||
cradle: | ||
none: | ||
- path: "./" | ||
config: | ||
cradle: | ||
stack: | ||
component: "disco:lib" | ||
cabal: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.