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

Encoding a binary search tree in data type

So, I have been trying to encode the property of being a Binary Search Tree (instead of just a binary tree) in a new data type in Idris. It seems to work reasonably well if just the data type is used (e.g. in the repl) to create new trees. This is…
0
votes
1 answer

Why can't the constraint between `n` and `plus n 0` be solved?

I'm trying to reload a source file containing the following Idris 2 function on the REPL: ||| Apply a function across all elements of a vector. ||| @function The function to apply. ||| @input_vector The vector whose elements will be given as an…
nicoty
  • 166
  • 11
0
votes
1 answer

Why can (and must) the variable x appear twice on the left side of the function definition? And what's the meaning?

I'm a green hand with Idris,and get confused with this definition, as I don't understand how it works. The definitionare as follows. sameS : (k : Nat)->(j : Nat)->(k = j)->((S k) = (S j)) sameS x x Refl=Refl
0
votes
1 answer

Counter with upper limit in Idris

I am reading "Type-driven development with Idris" now so I created one rather artificial example as an experiment. It's a counter which fails to type-check when trying to decrease a zero value. Here is the code: data Counter : Nat -> Type where …
Stefan Dorn
  • 569
  • 2
  • 13
0
votes
1 answer

Idris, typed addition (incrementation)

How can I write function like this data Wrap : Nat -> Type where Wrp : n -> Wrap n addOne : (n : Nat) -> Wrap (S n) addOne {n} = Wrp (S n) in a form like this addOne : (n : Nat) -> S n addOne {n} = S n or something similar? Thanks
R. Shirkhanov
  • 367
  • 3
  • 6
0
votes
1 answer

Interface constraints for interface instances in Idris

I am just starting to learn Idris coming from Haskell, and I'm trying to write some simple linear algebra code. I want to write a Num interface instance for Vect, but specifically for Vect n a with the constraint that a has a Num instance. In…
Oliver
  • 1,576
  • 1
  • 17
  • 31
0
votes
0 answers

In Idris, why do we need to ascribe the kind to type parameters when they have already been defined elsewhere?

Why do we write f : Type -> Type instead of just f below - is it not inferred from Functor f?: interface Functor f => Applicative (f : Type -> Type) where pure : a -> f a (<*>) : f (a -> b) -> f a -> f b f has already had its kind (or…
bbarker
  • 11,636
  • 9
  • 38
  • 62
0
votes
1 answer

Idris returning dependent type signature error with if statement in type definition

I'm working on a red black tree implementation in Idris. In this implementation, the node, in addition to carrying information about its value and colour, also carries information about its black height (which is the number of black nodes from that…
0
votes
0 answers

Idris function getting pattern matching error on red black tree implementation

I'm working on a red black tree implementation in Idris. In this implementation, the node, in addition to carrying information about its value and colour, also carries information about its black height (which is the number of black nodes from that…
0
votes
1 answer

How would a Void let you produce, or do, anything?

In Type-Driven Development with Idris, Brady says If you were able to provide a value of the empty type, you'd be able to produce a value of any type. In other words, if you have a proof that an impossible value has happened, you can do anything.…
joel
  • 6,359
  • 2
  • 30
  • 55
0
votes
1 answer

How to use data from Maybe as Vect size variable

I'm trying to write a simple program that asks the user about the list size and shows content from that list by index also by the user's input. But I've stuck. I have a function that builds a list by a number. Now I want to create another function…
ChessMax
  • 2,125
  • 1
  • 16
  • 16
0
votes
1 answer

Prove a property of a function with a decEq in it

It's easy to prove f : Nat -> Nat proveMe : (x : Nat) -> Maybe Nat proveMe x = if (f x) == 0 then Just 42 else Nothing theProof : (x : Nat) -> (f x = Z) -> (Just 42 = proveMe x) theProof x prf = rewrite prf in Refl But what if the calculation of…
Corylus
  • 736
  • 5
  • 16
0
votes
1 answer

What language is accepted by idris-proof-script-mode?

In Emacs, with idris-mode 20200522.808, when I load the file using C-c C-l, I'm presented with a list of holes, and the message "Press the [P] buttons to solve the holes interactively in the prover." The prover consists of two windows,…
Jason Orendorff
  • 42,793
  • 6
  • 62
  • 96
0
votes
1 answer

Type Function Aliases in Idris

Is it possible to define a short alias of a type function in Idris? While the following code type-checks, I'd like to have a shorter definition for AugentRow. import Data.Vect ColumnCount : Type ColumnCount = Nat Cell : Type Cell = Type Row :…
0
votes
2 answers

Write function type on multiple lines in Idris

How do I split a type declaration into multiple lines in Idris? Types should drive development. So they may become quite long and not fit on screen. Like this one: addMatrices : (augent : Vect rowCount (Vect columnCount element)) -> (addend: Vect…