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
5
votes
1 answer

Unifying len and S len would lead to infinite value

I am trying to make a function hpure that generates an hvect by repeating the same element until it reaches the required length. Each element may have a different type. Ex: If the argument was show each element would be a specialization of the show…
michaelmesser
  • 3,601
  • 2
  • 19
  • 42
5
votes
2 answers

How to constraint input type and output type to be the same?

I am going through Type driven development with Idris from Manning. An example is given that teaches how to restrict a function to a given type in a family of types. We have Vehicle type that uses PowerSource that is either Pedal or Petrol and we…
nohwnd
  • 826
  • 7
  • 13
5
votes
2 answers

Pattern matching on Type in Idris

Probably it's elementary but I don't understand why the following function answers 1 for fnc Nat and also, for fnc Integer, which is not even included as a pattern. fnc : Type -> Integer fnc Bool = 1 fnc Nat = 2
Attila Karoly
  • 951
  • 5
  • 13
5
votes
1 answer

What's the type for Dictionary/Map in Idris

How can I define one? I've not found any information about the matter in the documentation. Only about List and Vector.
Jodimoro
  • 4,355
  • 3
  • 11
  • 18
5
votes
1 answer

What's the intention behind Idris' `BorrowedType`?

In idris, there's a universe called UniqueType the values of the types in which can only be used once. As far as I know, it can be used to write high-performance code. But the fact that a value can only be used once is usually too limited, so…
盛安安
  • 1,110
  • 1
  • 8
  • 21
5
votes
1 answer

Multi-Parameter Sub-Classes in Idris

Inspired by this blog post and this code I thought I'd try some category theory in Idris using its interfaces (type-classes). I defined Category as follows, which works fine: interface Category (obj : Type) (hom : obj -> obj -> Type) where id : {a…
Lemming
  • 4,085
  • 3
  • 23
  • 36
5
votes
2 answers

Is it possible to create a type-level representation of generic ADTs?

Using Church encoding, it is possible to represent any arbitrary algebraic datatype without using the built-in ADT system. For example, Nat can be represented (example in Idris) as: -- Original type data Nat : Type where natSucc : Nat -> Nat …
5
votes
1 answer

Dependent types

A while ago I come across the programming language Idris which "unique selling point" seem to be dependent types. Can someone explain what dependent types are and what kind of problem they are addressing?
free_easy
  • 5,061
  • 3
  • 25
  • 39
5
votes
1 answer

Efficiently abstracting over datatype arity

As everyone knows, you can easily build n-tuples out of 2-tuples. record Twople (A B : Set) : Set where constructor _,_ field fst : A snd : B n-ple : List Set -> Set n-ple = foldr Twople Unit (Agda syntax, but it'll work in Idris, and…
Benjamin Hodgson
  • 42,952
  • 15
  • 108
  • 157
5
votes
2 answers

Generic Adder from Idris to Scala?

Type Driven Development with Idris presents the following generic adder approach: AdderType : (numArgs : Nat) -> Type AdderType Z = Int AdderType (S k) = (next : Int) -> AdderType k adder : (n : Nat) -> (acc : Int) -> AdderType n adder Z acc …
Kevin Meredith
  • 41,036
  • 63
  • 209
  • 384
5
votes
0 answers

High compilation time and CPU in Idris

I'm playing with a little formalisation in Idris and I'm having some strange behaviour: high compilation time and CPU usage for a function. The code is an regex pattern matching algorithm. First the regex definition: data RegExp : Type where Zero…
Rodrigo Ribeiro
  • 3,198
  • 1
  • 18
  • 26
5
votes
2 answers

Adding Two Lists of Same Size at Compile-time

In Idris, I can add two vectors of the same size via: module MatrixMath import Data.Vect addHelper : (Num n) => Vect k n -> Vect k n -> Vect k n addHelper = zipWith (+) After compiling it on the REPL: *MatrixMath> :l MatrixMath.idr Type checking…
Kevin Meredith
  • 41,036
  • 63
  • 209
  • 384
5
votes
1 answer

Using Idris to Model State Machine of Open-Close Door

At ScalaWorld 2015, Edwin Brady gave an exciting talk on Idris - https://www.youtube.com/watch?v=X36ye-1x_HQ. In one of the examples, I recall that he showed how to use Idris to write a program representing a Finite State Machine (FSM) - for opening…
Kevin Meredith
  • 41,036
  • 63
  • 209
  • 384
5
votes
2 answers

Primitive operations in proofs

For learning dependent types, I'm rewriting my old Haskell game in Idris. Currently the game „engine“ uses builtin integral types, such as Word8. I'd want to prove some lemmas involving numerical properties of those numbers (such as, that double…
Yuuri
  • 1,858
  • 1
  • 16
  • 26
5
votes
1 answer

Proof of stream's functor laws

I've been writing something similar to a Stream. I am able to prove each functor law but I can not figure out a way to prove that it's total: module Stream import Classes.Verified %default total codata MyStream a = MkStream a (MyStream…
Brian McKenna
  • 45,528
  • 6
  • 61
  • 60