concept algorithm in category idris

appears as: lgorithms, algorithm, n algorithm, lgorithm
Type-Driven Development with Idris

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

Idris modules can be combined into packages, from which individual modules can be imported. The Prelude is defined in a package called prelude, from which all modules are imported automatically. Idris programs also have access to a package called base, which defines several commonly useful data structures and algorithms including Vect, but from which modules must be imported explicitly. Up-to-date documentation for the packages distributed with Idris is available at www.idris-lang.org/documentation.

  • Refine— Trying an expression search on ?insSort_rhs_2 is, unfortunately, less effective:
    insSort : Vect n elem -> Vect n elem
    insSort [] = []
    insSort (x :: xs) = x :: xs
    Although Idris knows how long the vector should be, and it has local variables of the correct types, the overall type of insSort isn’t precise enough for Idris to fill in the hole with the program you intend.

    Expression search

    As this example demonstrates, although expression search can often lead you to a valid function, it’s not a substitute for understanding how the program works! You need to understand the algorithm, but you can use expression search to help fill in the details.


  • As this example demonstrates, although expression search can often lead you to a valid function, it’s not a substitute for understanding how the program works! You need to understand the algorithm, but you can use expression search to help fill in the details.