intellij-arend icon indicating copy to clipboard operation
intellij-arend copied to clipboard

Consider showing a type hint for function clauses

Open marat-rkh opened this issue 3 years ago • 4 comments

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 => {?}

marat-rkh avatar Apr 20 '21 19:04 marat-rkh

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

ice1000 avatar Apr 20 '21 23:04 ice1000

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.

marat-rkh avatar Apr 21 '21 08:04 marat-rkh

FWIW the 'show type' action is kinda expensive

ice1000 avatar Apr 21 '21 08:04 ice1000

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

marat-rkh avatar Apr 21 '21 09:04 marat-rkh