Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Idris (programming language)

From Wikipedia, the free encyclopedia
Functional programming language created in 2007
This articlerelies excessively onreferences toprimary sources. Please improve this article by addingsecondary or tertiary sources.
Find sources: "Idris" programming language – news ·newspapers ·books ·scholar ·JSTOR
(August 2019) (Learn how and when to remove this message)
Idris
ParadigmFunctional
Designed byEdwin Brady
First appeared2007; 18 years ago (2007)[1]
Stable release
Idris2 v0.8.0[2] / October 31, 2025; 1 day ago (2025-10-31)
Typing disciplineDependent
OSCross-platform
LicenseBSD
Filename extensions.idr, .lidr
Websiteidris-lang.org
Influenced by
Agda,Clean,[3]Rocq (previously known as Coq),[4]Epigram,F#,Haskell,[4]ML,[4]Rust[3]

Idris is apurely-functionalprogramming language withdependent types,quantity annotations, optionallazy evaluation, and features such as atotality checker. Idris is designed to be ageneral-purpose programming language similar toHaskell, but may also be used as aproof assistant.

The Idristype system is similar toAgda's. Compared to Agda, Idris prioritizes management ofside effects and support forembedded domain-specific languages. Idris is compiled by modular backends, which provide code generation and aruntime system.[5] The Idris compiler includes backends forChez Scheme,Racket,JavaScript (both browser- andNode.js-based), andC. Additional third-party backends are available for other platforms.[6]

Idris is named after a singing dragon from the 1970s UK children's television programmeIvor the Engine.[7]

Features

[edit]

Idris combines a number of features from relatively mainstream functional programming languages with features borrowed fromproof assistants.

Functional programming

[edit]

The syntax of Idris shows many similarities with that of Haskell. Ahello world program in Idris might look like this:

moduleMainmain:IO()main=putStrLn"Hello, World!"

The only differences between this program and itsHaskell equivalent are the single (instead of double) colon in thetype signature of the main function, and the omission of the word "where" in themodule declaration.[8]

Inductive and parametric data types

[edit]

Idris supportsinductively-defined data types andparametric polymorphism. Such types can be defined both in traditionalHaskell 98-like syntax:

dataTreea=Node(Treea)(Treea)|Leafa

or in the more generalgeneralized algebraic data type (GADT)-like syntax:

dataTree:Type->TypewhereNode:Treea->Treea->TreeaLeaf:a->Treea

Dependent types

[edit]

Withdependent types, it is possible for values to appear in the types; in effect, any value-level computation can be performed duringtype checking. The following defines a type of lists whose lengths are known before the program runs, traditionally calledvectors:

dataVect:Nat->Type->TypewhereNil:Vect0a(::):(x:a)->(xs:Vectna)->Vect(n+1)a

This type can be used as follows:

totalappend:Vectna->Vectma->Vect(n+m)aappendNilys=ysappend(x::xs)ys=x::appendxsys

The functionappend appends a vector ofm elements of typea to a vector ofn elements of typea. Since the precise types of the input vectors depend on a value, it is possible to be certain atcompile time that the resulting vector will have exactly (n +m) elements of typea.The word "total" invokes thetotality checker which will report an error if the functiondoesn't cover all possible cases or cannot be (automatically) proven not to enter aninfinite loop.

Another common example is pairwise addition of two vectors that are parameterized over their length:

totalpairAdd:Numa=>Vectna->Vectna->VectnapairAddNilNil=NilpairAdd(x::xs)(y::ys)=x+y::pairAddxsys

Num a signifies that the type a belongs to thetype classNum. Note that this function still typechecks successfully as total, even though there is no case matchingNil in one vector and a number in the other. Because the type system can prove that the vectors have the same length, we can be sure at compile time that case will not occur and there is no need to include that case in the function’s definition.

Proof assistant features

[edit]

Dependent types are powerful enough to encode most properties of programs, and an Idris program can prove invariants at compile time. This makes Idris into a proof assistant.

There are two standard ways of interacting with proof assistants: by writing a series of tactic invocations (Rocq style), or by interactively elaborating a proof term (Epigram–Agda style). Idris supports both modes of interaction, although the set of available tactics is not yet as useful as that of Rocq.[vague]

Code generation

[edit]

Because Idris contains a proof assistant, Idris programs can be written to pass proofs around. If treated naïvely, such proofs remain around at runtime. Idris aims to avoid this pitfall by aggressively erasing unused terms.[9][10]

By default, Idris generates native code throughC. The other officially supported backend generatesJavaScript.

Idris 2

[edit]

Idris 2 is a newself-hosted version of the language which deeply integrates alinear type system, based onquantitative type theory. It currently compiles toScheme andC.[11]

See also

[edit]

References

[edit]
  1. ^Brady, Edwin (12 December 2007)."Index of /~eb/darcs/Idris".University of St Andrews School of Computer Science. Archived fromthe original on 2008-03-20.
  2. ^"Release [v0.8.0] 2025 Hallowe'en Release".GitHub. Retrieved2025-08-31.
  3. ^ab"Uniqueness Types".Idris 1.3.1 Documentation. Retrieved2019-09-26.
  4. ^abc"Idris, a language with dependent types". Retrieved2014-10-26.
  5. ^"Compiling to Executables".Documentation for the Idris 2 Language. Retrieved1 November 2025.
  6. ^"External Backends".Idris2 Wiki. Retrieved1 November 2025.
  7. ^"Frequently Asked Questions". Retrieved2015-07-19.
  8. ^"Syntax Guide – Idris 1.3.2 documentation". Retrieved27 April 2020.
  9. ^"Erasure By Usage Analysis – Idris latest documentation".idris.readthedocs.org.
  10. ^"Benchmark results".ziman.functor.sk.
  11. ^"idris-lang/Idris2".GitHub. Retrieved2021-04-11.

External links

[edit]
Haskell programming
Software
Implementations
(features)
Dialects
Electronic
design
Libraries
Package managers
Windowing systems
Web frameworks
Book
Community
Eponym
Retrieved from "https://en.wikipedia.org/w/index.php?title=Idris_(programming_language)&oldid=1319841267"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp