Skip to content
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

Consider showing a type hint for function clauses #264

Open
marat-rkh opened this issue Apr 20, 2021 · 4 comments
Open

Consider showing a type hint for function clauses #264

marat-rkh opened this issue Apr 20, 2021 · 4 comments

Comments

@marat-rkh
Copy link
Member

Consider the following function:

\func -'+assoc (m n p : Nat): m -' n -' p = m -' (n + p)
  | m, n, 0 => [n-'0=n] (m -' n)
  | m, n, p => {?}

It is defined by pattern matching, so each clause has its own type. For example, the type of the first clause is m -' n -' 0 = m -' n. You cannot see that type when you read the code, and it could be a non trivial task to calculate it in your head. But knowing the type helps to understand why the proof on the right side of => looks the way it does. It would be nice if IDE could show me the type explicitly.

One way to do that is to use inlay type hints. An example in Kotlin:

Screen Shot 2021-04-20 at 10 27 25 PM

Here : List<Path!> is a hint that shows a type of the foo variable that is not specified explicitly. In Arend that might look like this:

\func -'+assoc (m n p : Nat): m -' n -' p = m -' (n + p)
  | m, n, 0 => [n-'0=n] (m -' n) : m -' n -' 0 = m -' n
  | m, n, p => {?}
@ice1000
Copy link
Collaborator

ice1000 commented Apr 20, 2021

Currently you can select an Arend expression and do Ctrl Shift P to show its type

@marat-rkh
Copy link
Member Author

Yeah, I use it. I believe type hints might be more convenient when you mostly read code. Selecting and invoking the action for each clause is too tedious.

@ice1000
Copy link
Collaborator

ice1000 commented Apr 21, 2021

FWIW the 'show type' action is kinda expensive

@marat-rkh
Copy link
Member Author

Oh, I see. That could be a problem, indeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants