concept contract in category idris

appears as: contracts, contract
Type-Driven Development with Idris

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

In this chapter, you’ll see how to express more-complex relationships between data using predicates. By expressing relationships between data in types, you can be explicit about the assumptions you’re making about the inputs to a function, and have those assumptions checked by the type checker when those functions are called. You can even think of these assumptions as expressing compile time contracts that other arguments must satisfy before anything can call the function.

Listing 9.2. Removing an element from a vector, with a contract specified in the type using Elem (RemoveElem.idr)