New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tc-env-lookup-value: suggest type constructors #1097
base: main
Are you sure you want to change the base?
Conversation
On variable lookup miss, existing suggestion code has no effect because it looks at the two places just checked. Instead check the environment to see if the var names a type, meaning, maybe the user was looking for a type constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
love this kind of usability enhancement. just some bitty things
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, would like @eliaslfox to peek too
@@ -4,6 +4,7 @@ | |||
#:coalton-impl/typechecker/base | |||
#:coalton-impl/typechecker/parse-type) | |||
(:local-nicknames | |||
(#:a #:alexandria) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't PLN alexandria.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'll accept the PLN
(#:the-library-of-alexandria #:alexandria)
however. send tweet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a compromise, it could be referred to via the Mongolian vowel separator jbouwman#2
"Look up a type binding of VAR-NAME in type checker environment ENV." | ||
(gethash var-name (tc-env-ty-table env))) | ||
|
||
(defun lookup-var (env var-name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't define this function.
@@ -47,57 +48,59 @@ | |||
|
|||
(tc:qualified-ty-type (tc:fresh-inst (setf (gethash name (tc-env-ty-table env)) (tc:to-scheme (tc:make-variable)))))) | |||
|
|||
(defun lookup-var-type (env var-name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't define this function.
(push (apply #'format nil fmt-string fmt-args) suggestions))) | ||
|
||
;; If the symbol names a type, user may have intended to use a type constructor | ||
(a:when-let ((type (tc:lookup-type (tc-env-env env) var-name :no-error t))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use when-let
(defun tc-env-suggest-value (env var-name) | ||
"If value lookup failed, generate suggestions for what to do, if anything." | ||
(let ((suggestions nil)) | ||
(flet ((suggest (fmt-string &rest fmt-args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just write this inline.
"Look up a variable binding of VAR-NAME in type checker environment ENV." | ||
(tc:lookup-value-type (tc-env-env env) var-name :no-error t)) | ||
|
||
(defun tc-env-suggest-value (env var-name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add type annotations to this function.
;; including checking other places in the environment and | ||
;; catching simple spelling errors. | ||
|
||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Paren goes on line 67
(defun tc-env-lookup-value (env var file) | ||
"Lookup a variable named VAR in ENV." | ||
"Lookup the value of a variable named VAR in ENV." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the type of
On variable lookup miss, existing suggestion code has no effect because it looks at the two places just checked. Instead check the environment to see if the var names a type, meaning, maybe the user was looking for a type constructor.
Closes #1095