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

Why does this function/constructor argument become a free implicit variable?

I'm trying to implement Agda's inspect idiom in Idris, as a possible workaround for this problem, however, it seems when I pattern match on the MkReveal constructor, the choice of f is lost and instead becomes a free parameter. First, the Idris port…
Cactus
  • 27,075
  • 9
  • 69
  • 149
0
votes
1 answer

Idris pattern matching on successor (next value)

On the following function I'm pattern matching on the Successor of k on (S k) vectTake : (n : Nat) -> Vect (n + m) a -> Vect n a vectTake Z xs = [] vectTake (S k) (x :: xs) = x :: vectTake k xs Is it possible to use that value on the body of the…
renanreismartins
  • 199
  • 1
  • 1
  • 14
0
votes
1 answer

Can I avoid explicitly discharging invalid cases in total functions in Idris?

Consider the following (very simplified) example of constraining a datatype via a side-condition on its values: data Transport = Car | Foot | Boat total wheels : (transport : Transport) -> {auto hasWheels : transport = Car} -> Int wheels Car…
Ganesh Sittampalam
  • 28,821
  • 4
  • 79
  • 98
0
votes
0 answers

Idris compilation from source failed

I'm trying to build latest dev version 1.3.2 of Idris from source code (bbd0f286c2e76ae157b5130303d29622d31de309) with these commands $ curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh $ cabal v1-sandbox init $ cabal update $…
Most Wanted
  • 6,254
  • 5
  • 53
  • 70
0
votes
2 answers

Cabal cannot resolve dependencies for Idris

I'm new to the Haskell ecosystem and trying to install Idris on my MacOS Catalina. So after $ brew install ghc $ brew install cabal-install I have The Glorious Glasgow Haskell Compilation System, version 8.8.2 and cabal-install version 3.0.0.0.…
Most Wanted
  • 6,254
  • 5
  • 53
  • 70
0
votes
0 answers

Idris impossible keyword proves a wrong proposition

data Even: Nat -> Type where EvenZ: Even Z EvenS: Even n -> Even (n + 2) total lemma1: Even Z lemma1 = EvenZ -- total -- lemma2: Even Z -- lemma2 impossible -- Idris says 'lemma2 is a valid case' and I agree with you total lemma3: Even…
0
votes
2 answers

How to make Idris warn of incomplete cases/matches?

For example when implementing a Show instance for the following type: data Shape = Circle Double | Box Vector2D | Polygon (List Vector2D) | Chain (List Vector2D) ...and omitting the Chain case, Idris will…
corazza
  • 31,222
  • 37
  • 115
  • 186
0
votes
1 answer

Idris: Is there a way to reference an abstracted variable in an equality proof?

The simplest example of the problem (but not the only example I can exhibit) is: suppose I'm given a higher order function f : (a -> b) -> c. I'd like to prove that f = (\g => f (\x => g x)). In my own reasoning, it should be pretty straightforward:…
0
votes
1 answer

Idris proof with RHS as function definition

I'm trying to get my head around some simple proofs by trying to prove the equivalence of a computational method of computing triangular numbers to the closed form of them. So far, all I've managed to achieve is this: total tn_eval : (n : Nat) ->…
AdamHarries
  • 335
  • 2
  • 11
0
votes
1 answer

Invoking (-) two times on different Nat variables within the same expression requires explicit proof annotation

Consider this definition: h : Nat -> Nat -> Nat h x y = case 1 `isLTE` x of (Yes prf) => case 1 `isLTE` y of (Yes prf') => (x - 1) * 2 + (y - 1) (No contra) => ?sr_3 …
Ignat Insarov
  • 4,660
  • 18
  • 37
0
votes
1 answer

Idris: Proving some contradiction cases

I am new to Idris and Proofs in general but I am progressing through Software Foundations ported to Idris. I am working on an exercise namespace Booleans data Bool = True | False andb : Booleans.Bool -> Booleans.Bool -> Booleans.Bool andb…
akaphenom
  • 6,728
  • 10
  • 59
  • 109
0
votes
1 answer

Implementing isLast with Idris: not in tail

I am working on exercise 2 in section 9.1 from Type-Driven Development with Idris, and I can't figure out how to fill the last hole (see notInTail, below). I have read the answers to Implementing isLast with Idris, but I am stuck in a different…
mhwombat
  • 8,026
  • 28
  • 53
0
votes
1 answer

Type mismatch involving three types that must be identical

This compiles: data ThreeEq : a -> b -> c -> Type where Same3 : (x : a) -> ThreeEq x x x allSameS : (x, y, z : Nat) -> ThreeEq x y z -> ThreeEq (S x) (S y) (S z) allSameS k k k (Same3 k) = Same3 (S k) But with one small change to Same3, it no…
mhwombat
  • 8,026
  • 28
  • 53
0
votes
1 answer

Working with types up to a certain equivalence

Suppose we'd like to represent (signed) integers as the Grothendieck group over naturals (or, in other words, as a pair (m, n), where the integer that's understood is m - n): data ZTy : Type where MkZ : (m, n : Nat) -> ZTy Now the (structural)…
0xd34df00d
  • 1,496
  • 1
  • 8
  • 17
0
votes
2 answers

Idris/cabal install issues from removePathRecursive on Windows

Installing Idris on Windows 10 using instructions to: Install Haskell following this Replaced , with ; in multiline paths of config files as reported by @gergelybat in this c:\Users\me\cabal update c:\Users\me\cabal install idris Several…
Algeboy
  • 270
  • 2
  • 9