Questions tagged [idris]

Idris is a general purpose pure functional programming language with dependent types.

Idris is a general-purpose purely functional programming language with dependent types, strict or optional lazy evaluation and features such as a totality checker.


Useful links:

785 questions
9
votes
1 answer

Using rewrite in the REPL

For one of the exercises in Type-Driven Development with Idris, I wrote the following: myPlusCommutes : (n : Nat) -> (m : Nat) -> n + m = m + n myPlusCommutes Z m = rewrite plusZeroRightNeutral m in Refl myPlusCommutes (S n) m = rewrite…
mhwombat
  • 8,026
  • 28
  • 53
9
votes
1 answer

What can Coq do while Agda/Idris can't do?

Coq is a proof assistant, while Agda/Idris are programming languages (although they can be called proof assistants). I was exploring these languages and I wonder if Agda/Idris are sufficient to do everything that Coq can do. So, is there some…
ice1000
  • 6,406
  • 4
  • 39
  • 85
9
votes
0 answers

How to extract the second element of Sigma on the Calculus of Constructions?

I'm attempting to do that as follows: λ (A : *) -> λ (B : (A -> *)) -> λ (t : (∀ (r : *) -> (∀ (x : a) -> (B x) -> r)) -> r) -> (t (B (t A (λ (x : A) -> λ (y : (B x)) -> x))) (λ (x : A) -> λ (y : (B x)) -> y)) Notice that, since the value…
MaiaVictor
  • 51,090
  • 44
  • 144
  • 286
9
votes
0 answers

Idris type system properties

Is it theoretically possible to convert any Coq proof to Idris or there are any limitations? More abstract question: Where does Idris type system fall on the lambda cube? The reason for these questions is that I'm trying to understand how (and if)…
svetlana
  • 308
  • 2
  • 8
9
votes
1 answer

Easy Syntactic Equality in Idris

Is there an easy way to write equality (DecEq) instances for data types? For example, I'd like the following to have O(n) lines in its DecEq declaration, where ?p is something simple: data Foo = A | B | C | D instance [syntactic] DecEq Foo where …
9
votes
1 answer

Sorted list in idris (insertion sort)

I am writing an undergraduate thesis on usefulness of dependent types. I am trying to construct a container, that can only be constructed into a sorted list, so that it is proven sorted by construction: import Data.So mutual data SortedList : (a…
bssstudio
  • 142
  • 7
8
votes
1 answer

Singletons of singletons (emulating complex pi types in Haskell)

I've got a simple proof of concept in Idris which uses dependent types to enforce some not-too-complex business logic. A few names have been changed to protect the not-so-innocent, but the idea is that we want to collect "lines" in a sequence. Each…
Derrick Turk
  • 4,246
  • 1
  • 27
  • 27
8
votes
2 answers

How can I have a constrained Finite State Machine in Haskell / Idris?

EDIT: Users @apocalisp and @BenjaminHodgson left awesome answers below, skip reading most of the question and jump to their answers. TLDR of the Question: How can I go from the first picture, where FSM states combinatorial explode, to the second…
Josh.F
  • 3,666
  • 2
  • 27
  • 37
8
votes
1 answer

Can Idris infer indices in types of top-level constants?

For example, Agda allows me to write this: open import Data.Vec open import Data.Nat myVec : Vec ℕ _ myVec = 0 ∷ 1 ∷ 2 ∷ 3 ∷ [] and myVec will have type Vec ℕ 4 as expected. But if I try the same in Idris: import Data.Vect myVec : Vect _…
Cactus
  • 27,075
  • 9
  • 69
  • 149
8
votes
1 answer

How can I have Idris automatically prove that two values are not equal?

How can I have Idris automatically prove that two values are not equal? p : Not (Int = String) p = \Refl impossible How can I have Idris automatically generate this proof? auto does not appear to be capable of proving statements involving Not. My…
michaelmesser
  • 3,601
  • 2
  • 19
  • 42
8
votes
1 answer

Idris REPL: creating function

How do I write a function in the Idris REPL ? If I type the function definition longer: string -> string -> string in the REPL, I get the following error message : (input):1:7: error: expected: "$", "&&", "*", "*>", "+", "++", "-", "->",…
Moebius
  • 6,242
  • 7
  • 42
  • 54
8
votes
1 answer

In Idris, how do I hide something defined in Prelude?

I want to define my own version of fib to play around with, but fib is exported by the Prelude. How do I hide the import from the Prelude? In Haskell I would write import Prelude hiding (fib), but that doesn't work in Idris.
Neil Mitchell
  • 9,090
  • 1
  • 27
  • 85
8
votes
1 answer

How exactly does rewrite work in Idris?

I wrote the following proposition in Idris: total plusOneCommutes : (n : Nat) -> (m : Nat) -> (n + S m = S n + m) plusOneCommutes Z k = Refl plusOneCommutes (S k) j = let inductiveHypothesis = plusOneCommutes k j in rewrite…
insitu
  • 4,488
  • 3
  • 25
  • 42
8
votes
1 answer

How to encode possible state transitions in type?

I am trying to replicate in Haskell this piece of Idris code, which enforces correct sequencing of actions through types: data DoorState = DoorClosed | DoorOpen data DoorCmd : Type -> DoorState -> DoorState -> Type…
insitu
  • 4,488
  • 3
  • 25
  • 42
8
votes
1 answer

Strange error message with Idris interfaces

I'm trying to implement a simple algebraic structures hierarchy using Idris interfaces. The code is as follows: module AlgebraicStructures -- definition of some algebraic structures in terms of type classes %access public export Associative : {a…
Rodrigo Ribeiro
  • 3,198
  • 1
  • 18
  • 26