Top Related Projects
Agda is a dependently typed programming language / interactive theorem prover.
Coq is a formal proof management system. It provides a formal language to write mathematical definitions, executable algorithms and theorems together with an environment for semi-interactive development of machine-checked proofs.
Lean Theorem Prover
A Coq library for Homotopy Type Theory
The core OCaml system: compilers, runtime system, base libraries
A strongly-typed language that compiles to JavaScript
Quick Overview
Idris-dev is the main repository for the Idris programming language, a dependently typed functional programming language that aims to provide a platform for writing verified programs. Idris is designed to make it easier to write programs that are correct by construction, with a focus on type-driven development and formal verification.
Pros
- Dependently Typed: Idris is a dependently typed language, which allows for more expressive and precise type systems, enabling the creation of programs that are more robust and less prone to errors.
- Formal Verification: Idris provides a platform for writing formally verified programs, allowing developers to prove the correctness of their code and catch errors at compile-time.
- Type-Driven Development: Idris encourages a type-driven development approach, where the type system is used to guide the implementation of the program, leading to more reliable and maintainable code.
- Powerful Type System: Idris has a powerful type system that includes features like dependent types, type classes, and pattern matching, which can help developers write more concise and expressive code.
Cons
- Steep Learning Curve: Idris has a relatively steep learning curve, especially for developers who are more familiar with traditional imperative or object-oriented programming languages.
- Limited Ecosystem: Compared to more mainstream programming languages, the Idris ecosystem is relatively small, with fewer libraries and tools available.
- Performance Concerns: Idris is a relatively new language, and there are some concerns about its performance compared to more established languages, especially for certain types of applications.
- Niche Use Case: Idris is primarily targeted at developers who are interested in formal verification and type-driven development, which may limit its broader adoption.
Code Examples
Here are a few short code examples that demonstrate some of the key features of Idris:
- Dependent Types:
data Vect : Nat -> Type -> Type
data Vect Z a = Nil
data Vect (S k) a = (::) a (Vect k a)
append : Vect n a -> Vect m a -> Vect (n + m) a
append Nil ys = ys
append (x :: xs) ys = x :: (append xs ys)
This code defines a Vect
type, which represents a vector of a fixed length. The type of the Vect
constructor encodes the length of the vector, ensuring that operations like append
are type-safe.
- Pattern Matching:
data Bool = True | False
not : Bool -> Bool
not True = False
not False = True
This code defines a simple not
function that takes a Bool
value and returns the opposite value, using pattern matching to define the function.
- Type Classes:
class Eq a where
(==) : a -> a -> Bool
(/=) : a -> a -> Bool
instance Eq Bool where
True == True = True
False == False = True
_ == _ = False
x /= y = not (x == y)
This code defines a type class Eq
that provides a way to define equality and inequality operations for a type. The example then provides an instance of Eq
for the Bool
type.
Getting Started
To get started with Idris, you can follow these steps:
- Install Idris by following the instructions for your operating system: https://www.idris-lang.org/download/
- Create a new Idris file (e.g.,
main.idr
) and write some basic code, such as the examples shown above. - Compile and run your Idris code using the
idris
command-line tool:idris main.idr -o main ./main
- Explore the Idris documentation and community resources to learn more about the language and its features: https://www.idris-lang.org/documentation/
Competitor Comparisons
Agda is a dependently typed programming language / interactive theorem prover.
Pros of Agda
- Agda has a more advanced type system, allowing for more expressive and precise specifications.
- Agda's type system supports dependent types, which can be used to encode complex properties and invariants.
- Agda has a more mature and well-documented standard library, providing a wide range of functionality.
Cons of Agda
- Agda has a steeper learning curve compared to Idris, especially for users new to dependent type systems.
- The Agda ecosystem is smaller than Idris, with fewer available libraries and tools.
- Agda's compiler and tooling are generally less user-friendly and more complex than Idris.
Code Comparison
Idris-dev:
data Nat : Type where
Z : Nat
S : Nat -> Nat
plus : Nat -> Nat -> Nat
plus Z y = y
plus (S x) y = S (plus x y)
Agda:
data Nat : Set where
zero : Nat
suc : Nat → Nat
_+_ : Nat → Nat → Nat
zero + n = n
suc m + n = suc (m + n)
The code snippets above show the definition of natural numbers and the addition operation in both Idris and Agda. The main differences are the syntax and the use of dependent types in Agda, which allows for more expressive type definitions.
Coq is a formal proof management system. It provides a formal language to write mathematical definitions, executable algorithms and theorems together with an environment for semi-interactive development of machine-checked proofs.
Pros of Coq
- Coq has a larger and more established user community compared to Idris, with a wealth of resources and support available.
- Coq's proof assistant features are more mature and robust, making it a popular choice for formal verification and theorem proving.
- Coq has a broader range of libraries and tools available, covering a wide variety of domains and use cases.
Cons of Coq
- Coq's syntax and learning curve can be more complex and challenging for beginners compared to Idris.
- Coq's development and maintenance are primarily driven by a large, academic community, which may result in a slower pace of innovation and feature updates.
- Coq's performance can be less efficient than Idris for certain types of computations, especially in the context of programming language implementation.
Code Comparison
Idris-dev (Idris):
data Nat = Z | S Nat
plus : Nat -> Nat -> Nat
plus Z y = y
plus (S x) y = S (plus x y)
Coq:
Inductive nat : Type :=
| O : nat
| S : nat -> nat.
Fixpoint plus (n m : nat) : nat :=
match n with
| O => m
| S p => S (plus p m)
end.
The code snippets above demonstrate the definition of natural numbers and the implementation of addition in both Idris and Coq. While the overall functionality is similar, the syntax and language-specific features differ between the two.
Lean Theorem Prover
Pros of Lean3
- Lean3 is a powerful and expressive theorem prover, allowing for the formal verification of complex mathematical and software systems.
- The Lean3 ecosystem includes a rich set of libraries and tools, making it a versatile choice for a wide range of applications.
- Lean3 has a strong focus on automation and proof automation, which can significantly improve the productivity of users.
Cons of Lean3
- Lean3 has a steeper learning curve compared to Idris-dev, requiring a deeper understanding of formal logic and theorem proving.
- The Lean3 community is smaller than the Idris-dev community, which may result in fewer available resources and support.
- Lean3 is primarily focused on theorem proving, while Idris-dev has a broader focus on functional programming and language design.
Code Comparison
Idris-dev:
data Nat = Z | S Nat
plus : Nat -> Nat -> Nat
plus Z y = y
plus (S x) y = S (plus x y)
Lean3:
inductive Nat : Type
| zero : Nat
| succ : Nat → Nat
def plus : Nat → Nat → Nat
| zero y := y
| (succ x) y := succ (plus x y)
The code snippets above demonstrate the definition of natural numbers and the implementation of addition in both Idris-dev and Lean3. While the overall approach is similar, the syntax and specific constructs used in each language differ, reflecting their respective design choices and priorities.
A Coq library for Homotopy Type Theory
Pros of Coq-HoTT
- Coq-HoTT provides a powerful and expressive type theory for formalizing mathematics and computer science concepts.
- The project has a strong focus on Homotopy Type Theory (HoTT), which offers a novel approach to reasoning about higher-dimensional structures.
- Coq-HoTT benefits from the robust and well-established Coq proof assistant, which has a large and active community.
Cons of Coq-HoTT
- Coq-HoTT may have a steeper learning curve compared to Idris-dev, as it requires familiarity with both Coq and HoTT.
- The project may have a narrower focus on HoTT, which may not be as applicable to a broader range of programming tasks as Idris-dev.
- Coq-HoTT may have a smaller community and fewer resources available compared to the Idris-dev project.
Code Comparison
Idris-dev (Idris):
data Nat = Z | S Nat
plus : Nat -> Nat -> Nat
plus Z y = y
plus (S x) y = S (plus x y)
Coq-HoTT (Coq):
Inductive nat : Type :=
| O : nat
| S : nat -> nat.
Fixpoint plus (n m : nat) : nat :=
match n with
| O => m
| S p => S (plus p m)
end.
The core OCaml system: compilers, runtime system, base libraries
Pros of OCaml
- Mature and Widely Used: OCaml has been around since the 1990s and has a large and active community, with a wealth of libraries and tools available.
- Powerful Type System: OCaml's type system is highly expressive, allowing for advanced type-level programming and ensuring a high degree of safety and correctness.
- Efficient Compilation: OCaml code is compiled to efficient native code, making it a good choice for performance-critical applications.
Cons of OCaml
- Steeper Learning Curve: Compared to Idris, OCaml has a steeper learning curve, especially for developers coming from more mainstream languages like Java or Python.
- Limited Dependent Types: While OCaml has a powerful type system, it lacks the full dependent type capabilities of Idris, which can be useful for certain types of formal verification and program synthesis.
- Smaller Ecosystem: The Idris ecosystem, while growing, is smaller than the OCaml ecosystem, with fewer libraries and tools available.
Code Comparison
Here's a simple example of a function that computes the factorial of a number in both OCaml and Idris:
OCaml:
let rec factorial n =
if n = 0 then 1 else n * factorial (n - 1)
Idris:
factorial : Nat -> Nat
factorial 0 = 1
factorial n = n * factorial (n - 1)
The OCaml version uses a standard recursive definition, while the Idris version leverages the built-in Nat
type and pattern matching to achieve the same functionality.
A strongly-typed language that compiles to JavaScript
Pros of purescript/purescript
- Mature and Stable: PureScript has been around for a longer time than Idris, with a more established ecosystem and a larger community.
- Extensive Documentation: PureScript has excellent documentation, making it easier for newcomers to get started and learn the language.
- Powerful Type System: PureScript's type system is highly expressive, allowing for advanced type-level programming.
Cons of purescript/purescript
- Steeper Learning Curve: PureScript has a steeper learning curve compared to Idris, especially for those new to functional programming.
- Limited Dependent Types: While PureScript has a powerful type system, it lacks the full dependent type capabilities of Idris.
- Smaller Community: PureScript has a smaller community compared to Idris, which may result in fewer resources and support available.
Code Comparison
Here's a brief code comparison between Idris and PureScript:
Idris:
data List a = Nil | (::) a (List a)
length : List a -> Nat
length Nil = 0
length (x :: xs) = 1 + length xs
PureScript:
data List a = Nil | Cons a (List a)
length :: forall a. List a -> Int
length Nil = 0
length (Cons _ xs) = 1 + length xs
The code snippets demonstrate the similar structure of the List
data type and the length
function in both Idris and PureScript. The main differences are the syntax and the use of Nat
(natural numbers) in Idris versus Int
in PureScript.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Idris 1
Idris (https://idris-lang.org/) is a general-purpose functional programming language with dependent types.
Installation
This repository represents the latest development version of the language, and may contain bugs that are being actively worked on. For those who wish to use a more stable version of Idris please consider installing the latest version that has been released on Hackage. Installation instructions for various platforms can be found on the Idris Wiki.
More information about building Idris from source has been detailed in the Installation Guide
Code Generation
Idris has support for external code generators. Supplied with the distribution
is a C code generator to compile executables, and a JavaScript code generator
with support for node.js
and browser JavaScript.
More information about code generators can be found here.
Status
This is Idris 1, implemented in Haskell. Idris 1 is not actively worked on anymore.
Idris 2 is the next generation of Idris, and where primary development happens.
More Information
If you would like to find out more information, or ask questions, we
currently have a Wiki;
a mailing list,
and an IRC
channel #idris
on libera. To join the IRC channel,
point your irc client to irc.libera.chat
then /join #idris
.
For those further interested in using Idris for projects, the Idris Hackers GitHub organisation is where some interesting projects are being hosted.
For those interested in contributing to Idris directly we kindly ask that prospective developers please consult the Contributing Guide first.
Top Related Projects
Agda is a dependently typed programming language / interactive theorem prover.
Coq is a formal proof management system. It provides a formal language to write mathematical definitions, executable algorithms and theorems together with an environment for semi-interactive development of machine-checked proofs.
Lean Theorem Prover
A Coq library for Homotopy Type Theory
The core OCaml system: compilers, runtime system, base libraries
A strongly-typed language that compiles to JavaScript
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot