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

I can't prove (n - 0) = n with Idris

I am trying to prove, what to my mind is a reasonable theorem: theorem1 : (n : Nat) -> (m : Nat) -> (n + (m - n)) = m Proof by induction gets to the point where me need to prove this: lemma1 : (n : Nat) -> (n - 0) = n This is what happens when I…
Vic Smith
  • 3,477
  • 1
  • 18
  • 29
14
votes
1 answer

How do I prove a "seemingly obvious" fact when relevant types are abstracted by a lambda in Idris?

I am writing a basic monadic parser in Idris, to get used to the syntax and differences from Haskell. I have the basics of that working just fine, but I am stuck on trying to create VerifiedSemigroup and VerifiedMonoid instances for the…
14
votes
2 answers

Replicating the 'Taint mode' from 'Fortify static checking tool' in Haskell

I've read some documentation of the Fortify static checking tool. One of the concepts used by this tool are called taints. Some sources, such as web requests, provide data that is tainted in one or more ways and some sinks, such as web responses,…
aleator
  • 4,436
  • 20
  • 31
13
votes
1 answer

In Idris, can I prove free theorems, e.g. the only (total) function of type `forall t. t -> t` is `id`?

For sufficiently polymorphic types, parametricity can uniquely determine the function itself (see Wadler's Theorems for free! for details). For example, the only total function with type forall t. t -> t is the identity function id. Is it possible…
Philip Dorrell
  • 1,658
  • 11
  • 15
13
votes
1 answer

Why there is no filter function of Stream in idris?

There is filter : (a -> Bool) -> List a -> List a for List, but there is no filter : (a -> Bool) -> Stream a -> Stream a for Stream, why? Is there some alternatives to do the similar jobs?
luochen1990
  • 3,689
  • 1
  • 22
  • 37
13
votes
3 answers

Haskell version of Idris !-notation (bang notation)

I've had the luxury of learning a bit of Idris lately and one thing I've found extremely convenient is the !-notation, which let's me shorten monadic code inside a do block such as a' <- a b' <- b c' <- c someFunction a' b' c' to the much…
Karl
  • 1,143
  • 6
  • 20
13
votes
3 answers

How can I establish a bijection between a tree and its traversal?

I was looking at How does inorder+preorder construct unique binary tree? and thought it would be fun to write a formal proof of it in Idris. Unfortunately, I got stuck fairly early on, trying to prove that the ways to find an element in a tree…
dfeuer
  • 48,079
  • 5
  • 63
  • 167
13
votes
1 answer

Postulates in Idris

Is there any up to date information regarding the nature and use of the postulate construct in Idris? There is nothing on the subject in the tutorial/manual and I can't seem to find anything in the wiki as well. TIA.
Arets Paeglis
  • 3,856
  • 4
  • 35
  • 44
13
votes
1 answer

Is it possible to use guards in function definition in idris?

In haskell, one could write : containsTen::Num a => Eq a => [a] -> Bool containsTen (x : y : xs) | x + y == 10 = True | otherwise = False Is it possible to write something equivalent in Idris, without doing it with ifThenElse (my real case…
Molochdaa
  • 2,158
  • 1
  • 17
  • 23
13
votes
1 answer

Converting Coq to Idris

What would be some useful guidelines for converting Coq source to Idris (e.g. how similar are their type systems and what can be made of translating the proofs)? From what I gather, Idris' built-in library of tactics is minimal yet extendable, so I…
Arets Paeglis
  • 3,856
  • 4
  • 35
  • 44
12
votes
1 answer

Why doesn't (*3) `map` (+100) work in Idris?

In Haskell, functions are functors and the following code works as expected: (*3) `fmap` (+100) $ 1 The output is 303 of course. However, in Idris (with fmap -> map), it gives the following error: Can't find implementation for Functor (\uv =>…
corazza
  • 31,222
  • 37
  • 115
  • 186
12
votes
2 answers

What is the preferred alternative to Fin from Idris in Haskell

I would like to have a type which can contain values 0 to n, where n lives on the type level. I was trying something like: import GHC.TypeLits import Data.Proxy newtype FiniteNat n = FiniteNat { toInteger :: Integer } smartConstructFiniteNat ::…
user1747134
  • 2,374
  • 1
  • 19
  • 26
12
votes
1 answer

Is Idris really "strictly evaluated?"

Coming from Haskell, I was reading about Idris' story regarding laziness (non-strictness). I trolled the recent release notes, and found code akin to the following myIf : (b : Bool) -> (t : Lazy a) -> (e : Lazy a) -> a myIf True t e = t myIf False t…
mjgpy3
  • 8,597
  • 5
  • 30
  • 51
11
votes
0 answers

In Idris, why do interface parameters have to be type or data constructors?

To get some practice with Idris, I've been trying to represent various basic algebraic structures as interfaces. The way I thought of organizing things at first was to make the parameters of a given interface be the set and the various operations…
greatBigDot
  • 505
  • 3
  • 9
11
votes
1 answer

Pattern Match on Equality

I'm sort of new to Idris. I've used a little agda before, and I have a heavy background in GHC Haskell. I'm trying to understand why something that works in GHC Haskell doesn't work in Idris. The following code does not compile (idris version…
1 2
3
52 53