concept finite time in category idris

appears as: finite time, finite time
Type-Driven Development with Idris

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

Idris supports an even stronger property than purity for functions, making a distinction between partial and total functions. A total function is guaranteed to produce a result, meaning that it will return a value in a finite time for every possible well-typed input, and it’s guaranteed not to throw any exceptions. A partial function, on the other hand, might not return a result for some inputs. Here are a couple of examples:

Listing 11.14. Converting an expression of type InfIO to an executable IO action running for a finite time (InfIO.idr)

  

If a function is total, it will never crash due to a missing case (that is, all well-typed inputs are covered), and it will always return a well-typed result within a finite time. The functions you’ve written in previous chapters have all taken finite data as inputs, so they’re total as long as they terminate for all inputs. But now that you’ve seen the Inf type, you’re able to write functions that produce infinite data, and these functions don’t terminate! We’ll therefore need to refine our understanding of what it means for a function to be total.