concept new function in category idris

appears as: new function
Type-Driven Development with Idris

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

  • Type— In ?insSort_rhs_2 you’re going to insert the head x into the sorted tail, xsSorted. Because this is going to be a little more complex, you can lift the hole to a top-level definition by pressing Ctrl-Alt-L with the cursor over ?-insSort_rhs_2, which leads to the following:
    insSort_rhs_2 : (x : elem) -> (xs : Vect k elem) ->
                    (xsSorted : Vect k elem) ->
                    Vect (S k) elem
    
    insSort : Vect n elem -> Vect n elem
    insSort [] = []
    insSort (x :: xs) = let xsSorted = insSort xs in
                            insSort_rhs_2 x xs xsSorted
    This has created a new top-level function with a new type but no implementation, and it has replaced the hole with a call to the new function. The arguments to the new function are the local variables that were in scope in the hole ?insSort_rhs_2.