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
6
votes
4 answers

How can I create a function that only accepts a subset of constructors of a type?

Let's say I have a type like this: data Foo = Bar String | Baz | Qux String I want to have a function like this: get : Foo -> String get (Bar s) = s get (Qux s) = s As written, this compiles, but it's not total, as there are missing cases; in…
Sam Estep
  • 12,974
  • 2
  • 37
  • 75
6
votes
1 answer

In Idris, is "Eq a" a type, and can I supply a value for it?

In the following, example1 is standard syntax (as documented), with Eq a as a constraint. In example2, I specify Eq a directly as the type of a parameter, and the compiler accepts it. However it is unclear what I can specify as a value of that type.…
Philip Dorrell
  • 1,658
  • 11
  • 15
6
votes
0 answers

Converting old-style Idris proofs to elaborator scripts

What would be some of the recommended guidelines for converting the old-style Idris proofs to the new elaborator reflection-based ones? I have a substantial amount of Idris code written in the old (pre-ER) style and, while some of the tactics…
Arets Paeglis
  • 3,856
  • 4
  • 35
  • 44
6
votes
1 answer

What is the exact difference between Fix and Self on the Calculus of Constructions?

The Self Types for Dependently Typed Lambda Encodings paper (by Peng Fu and Aaron Stump) proposes self types, which are, supposedly, sufficient to encode the induction principle and Scott-encoded datatypes on the Calculus of Constructions, without…
MaiaVictor
  • 51,090
  • 44
  • 144
  • 286
6
votes
0 answers

Is it possible to use the Idris FFI as an Effect?

Suppose I have a function of type Eff () [STDIO] in Idris. This lets you do basic console I/O operations, but does not allow you to use Idris' foreign function interface. Is there an effect in idris that lets you do this, or some other way to get…
Nathan BeDell
  • 2,263
  • 1
  • 14
  • 25
6
votes
2 answers

What are good examples of programs that are simple to specify as dependent types, but complex to implement?

Last year I asked "Dependent types can prove your code is correct up to a specification. But how do you prove the specification is correct?". The most voted answer presents the following reasoning: The hope is that your specification is simple and…
MaiaVictor
  • 51,090
  • 44
  • 144
  • 286
6
votes
1 answer

How can I call a subprocess in Idris?

Is there some module in the Idris standard library (or a third party library) that allows one to shell out to another program? I'm thinking of modules like Python's subprocess and Haskell's System.Process. Ideally, I'd like to interact…
Langston
  • 1,083
  • 10
  • 26
6
votes
2 answers

How to Compare Types for Equality?

I attempted to compare a String and String, expecting True. Idris> String == String Can't find implementation for Eq Type Then I expected False when comparing a String to a Bool. Idris> String /= Bool Can't find implementation for Eq Type Am I…
Kevin Meredith
  • 41,036
  • 63
  • 209
  • 384
6
votes
1 answer

Does Idris have an equivalent to Agda's `_` expressions?

In addition to having implicit arguments, Agda lets you omit the value of an explicit argument and replace it with a metavariable, denoted by the _ character, whose value is then determined through the same procedure as implicit resolution. Does…
jmite
  • 8,171
  • 6
  • 40
  • 81
6
votes
1 answer

How do I convince the totality checker in Idris that I'm not using a variable?

I've been having trouble convincing the Idris totality checker that my function is total. Here's a simple example version of the problem I'm running into. Say we have a very simple expression type of the following form: data SimpleType = Prop | Fn…
So8res
  • 9,856
  • 9
  • 56
  • 86
6
votes
1 answer

Idris : Is it possible to rewrite all functions using "with" to use "case" instead of "with" ? If not, could you give a counter example?

In Idris, is it possible to rewrite all functions using "with" to use "case" instead of "with" ? If not, could you give a counter example ?
jhegedus
  • 20,244
  • 16
  • 99
  • 167
6
votes
1 answer

Why won't Idris accept my custom fold?

Here's a vector whose elements are indexed by the length of the vector. data IxVect : (n : Nat) -> (a : Nat -> Type) -> Type where Nil : IxVect 0 a (::) : a n -> IxVect n a -> IxVect (S n) a I want to fold up an IxVect. total foldr : {b :…
Benjamin Hodgson
  • 42,952
  • 15
  • 108
  • 157
6
votes
1 answer

What's a good way to represent free groups?

It's easy to represent free magmas (binary leaf trees), free semigroups (non-empty lists), and free monoids (lists), and not hard to prove that they actually are what they claim to be. But free groups seem a lot trickier. There seem to be at least…
dfeuer
  • 48,079
  • 5
  • 63
  • 167
6
votes
1 answer

Maintaining a Nat within a fixed range

I'd like to have a Nat that remains within a fixed range. I would like functions incr and decr that fail if they are going to push the number outside the range. This seems like it might be a good use case for Fin, but I'm not really sure how to make…
mushroom
  • 6,201
  • 5
  • 36
  • 63
6
votes
1 answer

Does Idris have an equivalent to Agda's ↔

Agda makes use of the following operator to show inverses between sets: _↔_ : ∀ {f t} → Set f → Set t → Set _ Is there an equivalent in Idris? I'm trying to define bag equality on lists data Elem : a -> List a -> Type where Here : {xs : List a}…
Vic Smith
  • 3,477
  • 1
  • 18
  • 29