Values in Idris
Idris has various value types including strings, integers, floats, booleans, etc. Here are a few basic examples.
Strings in Idris can be concatenated using the ++
operator.
Integers and floats work as expected. Note that in Idris, you need to use show
to convert numbers to strings for printing.
Booleans in Idris work with the standard boolean operators. The not
function is used for boolean negation.
To run this program, save it as values.idr
and use the Idris interpreter:
In Idris, we first compile the program to an executable using idris
, and then run the resulting executable.
Idris is a pure functional language with dependent types, which makes it quite different from imperative languages. This example demonstrates some basic value types and operations, but keep in mind that Idris has many more advanced features, particularly in its type system.