Content deleted Content added
Omnipaedista (talk | contribs) clarification |
Added in the list of statically typed programming languages (as described in 'Typing discipline'). |
||
(39 intermediate revisions by 23 users not shown) | |||
Line 1:
{{Short description|Functional programming language created in 2007}}
{{Primary sources|date=August 2019}}
{{Infobox programming language
| name = Idris
| paradigm = [[
| designer = Edwin Brady
| developer =
| released = {{Start date and age|2007}}<ref>{{cite web |last=Brady |first=Edwin |date=2007-12-12 |title=Index of /~eb/darcs/Idris |url=http://www-fp.cs.st-and.ac.uk/~eb/darcs/Idris/ |website=[[University of St Andrews]] School of Computer Science |
|
|
| latest preview version = 0.7.0 (Idris 2)<ref>{{Cite web |title=Idris 2 version 0.7.0 Released |website=[[GitHub]] |url=https://github.com/idris-lang/Idris2/releases/tag/v0.7.0 |access-date=2024-04-20}}</ref>
| latest preview date = {{Start date and age|2023|12|22}}
| typing = [[Type inference|Inferred]], [[Static typing|static]], [[Strong and weak typing|strong]]
| implementations =
| dialects =
|
| influenced =
|
| license = [[BSD licenses|BSD]]
| file ext = .idr, .lidr
Line 22:
}}
'''Idris''' is a [[purely functional programming|purely
The Idris [[type system]] is similar to [[Agda (programming language)|Agda]]'s, and proofs are similar to [[Coq (software)|Coq]]'s, including
Idris is named after a singing dragon from the 1970s UK children's television program ''[[Ivor the Engine#Idris the Dragon|Ivor the Engine]]''.<ref>{{cite web |title=Frequently Asked Questions |url=http://docs.idris-lang.org/en/latest/faq/faq.html#what-does-the-name-idris-mean |
▲Idris is named after a singing dragon from the 1970s UK children's television program ''[[Ivor the Engine#Idris the Dragon|Ivor the Engine]]''.<ref>{{cite web|title=Frequently Asked Questions|url=http://docs.idris-lang.org/en/latest/faq/faq.html#what-does-the-name-idris-mean|accessdate=2015-07-19}}</ref>
==Features==
Line 35 ⟶ 33:
===Functional programming===
The syntax of Idris shows many similarities with that of Haskell. A [[hello world program]] in Idris might look like this:
<
module Main
main : IO ()
main = putStrLn "Hello, World!"
</syntaxhighlight>
The only differences between this program and its [[Haskell
===Inductive and parametric data types===
Idris supports [[inductively-defined data type]]s and [[parametric polymorphism]].
<
data Tree a = Node (Tree a) (Tree a) | Leaf a
</syntaxhighlight>
or in the more general [[
<
data Tree : Type -> Type where
Node : Tree a -> Tree a -> Tree a
Leaf : a -> Tree a
</syntaxhighlight>
===Dependent types===
With [[dependent type]]s, it is possible for values to appear in the types; in effect, any value-level computation can be performed during [[
<
data Vect : Nat -> Type -> Type where
Nil : Vect 0 a
(::) : (x : a) -> (xs : Vect n a) -> Vect (n + 1) a
</syntaxhighlight>
This type can be used as follows:
<
total
append : Vect n a -> Vect m a -> Vect (n + m) a
append Nil ys = ys
append (x :: xs) ys = x :: append xs ys
</syntaxhighlight>
The
The word "<code>total</code>" invokes the [[Termination analysis|totality checker]] which will report an error if the function [[Partial function|doesn't cover all possible cases]] or cannot be (automatically) proven not to enter an [[infinite loop]].
Another common example is pairwise addition of two vectors that are parameterized over their length:
<
total
pairAdd : Num a => Vect n a -> Vect n a -> Vect n a
pairAdd Nil Nil = Nil
pairAdd (x :: xs) (y :: ys) = x + y :: pairAdd xs ys
</syntaxhighlight>
<code>Num</code> a signifies that the type a belongs to the [[type class]] <code>Num</code>. Note that this function still typechecks successfully as total, even though there is no case matching <code>Nil</code> in one vector and a number in the other.
===Proof assistant features===
Dependent types are powerful enough to encode most properties of programs, and an Idris program can prove invariants at compile
There are two standard ways of interacting with proof assistants: by writing a series of tactic invocations (
===Code generation===
Because Idris contains a proof assistant, Idris programs can be written to pass proofs around.
By default, Idris generates native code through [[C (programming language)|C]]. The other officially supported backend generates [[JavaScript]].
==Idris 2==
Idris 2 is a new [[Self-hosting (compilers)|self-hosted]] version of the language which deeply integrates a [[linear type system]], based on [[quantitative type theory]]. It currently compiles to [[Scheme (programming language)|Scheme]] and [[C (programming language)|C]].<ref>{{Cite web |title=idris-lang/Idris2 |url=https://github.com/idris-lang/Idris2 |access-date=2021-04-11 |website=GitHub |language=en}}</ref>
==See also==
* [[List of proof assistants]]
* [[Total functional programming]]
==References==
{{
==External links==
*
* [http://hackage.haskell.org/package/idris Idris at the Hackage repository]
* [http://docs.idris-lang.org/en/latest/index.html Documentation for the Idris Language (tutorial, language reference, etc.)]
{{Haskell programming}}
{{Programming languages}}
Line 119 ⟶ 122:
[[Category:Free software programmed in Haskell]]
[[Category:Haskell programming language family]]
[[Category:Articles with example Haskell code]]
[[Category:Cross-platform free software]]
[[Category:Free
[[Category:Software using the BSD license]]
[[Category:Programming languages created in 2007]]
Line 126 ⟶ 130:
[[Category:2007 software]]
[[Category:Pattern matching programming languages]]
[[Category:Statically typed programming languages]]
|