concept Int in category idris

appears as: Int, n Int, Int
Type-Driven Development with Idris

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

  • In getStringOrInt, StringOrInt calculates the return type. If the input is True, getStringOrInt returns an Int; otherwise it returns a String.
  • In valToString, StringOrInt calculates an argument type. If the first input is True, the second input must be an Int; otherwise it must be a String.
  • Function types are composed of one or more input types and an output type. For example, a function that takes an Int as input and returns another Int would be written as Int -> Int. The following listing shows a simple function definition with this type, the double function.

    Listing 2.2. A function to double an Int (Double.idr)
    
      
  • Int—A fixed-width signed integer type. It’s guaranteed to be at least 31 bits wide, but the exact width is system dependent.
  • Integer—An unbounded signed integer type. Unlike Int, there’s no limit to the size of the numbers that can be represented, other than your machine’s memory, but this type is more expensive in terms of performance and memory usage.