concept correct type in category idris

appears as: correct types, correct type
Type-Driven Development with Idris

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

  • 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.


  • In the rest of this chapter, we’ll extend the data store by adding schemas to describe the form of the data. We’ll determine the schema by user input, and we’ll use type-level functions to compute the correct type for the data. Figure 6.4 shows two different data stores, with different schemas, that we’ll be able to represent with our extended system. Schema 1, at the top, shows a store that requires the data to be of type (Int, String), and schema 2, below, shows a store that requires the data to be of type (String, String, Int). In contrast, in the data store developed in chapter 4, the schema was effectively always String.