concept interactive editing in category idris

appears as: interactive editing
Type-Driven Development with Idris

This is an excerpt from Manning's book Type-Driven Development with Idris.

  • Define— You now need to check x < y and act on the result. One way to do this is with an if...then...else construct:
    insert : Ord elem =>
             (x : elem) -> (xsSorted : Vect k elem) -> Vect (S k) elem
    insert x [] = [x]
    insert x (y :: xs) = if x < y then x :: y :: xs
                                  else y :: insert x xs
    Alternatively, you can use interactive editing to give more structure to the definition, and insert a case construct to match on an intermediate result. Press Ctrl-Alt-M with the cursor over ?insert_rhs_2. This introduces a new case expression with a placeholder for the value to be inspected (so the function won’t type-check yet):
    insert : Ord elem =>
             (x : elem) -> (xsSorted : Vect k elem) -> Vect (S k) elem
    insert x [] = [x]
    insert x (y :: xs) = case _ of
                              case_val => ?insert_rhs_2
    The _ stands for an expression you need to provide in order for the function to type-check successfully. You’ll need to fill in the _ with the expression you want to match:
    insert : Ord elem =>
             (x : elem) -> (xsSorted : Vect k elem) -> Vect (S k) elem
    insert x [] = [x]
    insert x (y :: xs) = case x < y of
                              case_val => ?insert_rhs_2
  • Interactive editing in Atom involves a number of keyboard commands in the editor, which are summarized in table 3.1.