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

How to do basic pattern matching with formal parameters (value binding) in Idris?

When I try this in Idris, contrived : (List a, Char, (Int, Double), String, Bool) -> Bool contrived ([] , 'b', (1, 2.0), "hi" , True) = False contrived (a, b, c, d, e) = True I receive the error message Can't infer argument a to…
bbarker
  • 11,636
  • 9
  • 38
  • 62
0
votes
1 answer

Compilation error while implementing extensible record

I'm playing around with idris and was trying to implement extensible records. The main goal is to guarantee that the record's keys are unique. For example ("Year" := 1998) +: rnil is legal ("Title" := "test") +: ("Year" := 1998) +: rnil also…
Julien Tournay
  • 544
  • 3
  • 7
0
votes
1 answer

Why does guard need the Ord typeclass in Idris?

In another question (How to write a simple list-based quicksort in Idris?), I was left trying to understand why Prelude.Applicative.guard requires an Ord typeclass. Guard is defined like this: guard : Alternative f => Bool -> f () guard a = if a…
bbarker
  • 11,636
  • 9
  • 38
  • 62
0
votes
0 answers

Why isn't this hole's context normalizing?

On the following program: module Bytes import Data.Fin %default total Byte : Type Byte = Fin 256 fromNat : Nat -> Byte fromNat n = maybe FZ (\x=>x) (natToFin n 256) toNat : Byte -> Nat toNat FZ = Z toNat (FS b) = S (toNat b) prop : (b :…
MaiaVictor
  • 51,090
  • 44
  • 144
  • 286
0
votes
1 answer

Can't disambiguate name: Prelude.List.++, Prelude.Strings.++ error in Idris

Currently I am trying to create a function that takes the type of (a -> a -> a) as a parameter in Idris and the right function to do is the ++ command for lists in idris unfortunately I am getting this error ListMonoid : (A : Type) ->…
Joshua Norris
  • 15
  • 1
  • 3
0
votes
1 answer

Idris in atom editor, "Couldn't find Idris executable" error

I am currently trying to download and use Idris for Atom and use it's editor. I downloaded Hackage and then installed idris on my computer from there and then installed the idris package on atom, and when ever I type in the program it highlights…
Joshua Norris
  • 15
  • 1
  • 3
0
votes
1 answer

Idris - Can I express that two type parameters are equal in a pattern match?

Lets say I have the following data Expr : Type -> Type where Lift : a -> Expr a Add : Num a => Expr a -> Expr a -> Expr a Cnst : Expr a -> Expr b -> Expr a data Context : Type -> Type where Root : Context () L : Expr w -> Context x ->…
Donovan
  • 69
  • 5
0
votes
2 answers

How to put things with different type into a list, tagged by string?

I'm trying to put things with different type into a list, tagged by string. What I want is something like that: arr1 : ?what_should_that_be arr1 = [("num" ** 1), ("str" ** "hello")] So I tried to prove that what I given as a tag is actually a valid…
luochen1990
  • 3,689
  • 1
  • 22
  • 37
0
votes
1 answer

How to prove that a string is in hexadecimal format?

How can I use Idris to build a function that, given a string, returns a proof that such String is hexadecimal (i.e., 0x followed by 2*N characters from 0-9 and a-f, such as "0x1a7f33b8")? What I tried First, I've constructed the following type for…
MaiaVictor
  • 51,090
  • 44
  • 144
  • 286
0
votes
1 answer

How to complete this proof of commutativity with `replace`?

On this documentation, it is mentioned how replace could be used to complete the proof, but it ends up using rewrite, which seems to be a syntax sugar that writes replace for you. I'm interested in understanding how to use it explicitly. If I…
MaiaVictor
  • 51,090
  • 44
  • 144
  • 286
0
votes
1 answer

Idris - equality assertion fails

Please consider the following function, even if the implementation is not that relevant: vectTranspose : Vect n (Fin 3) -> Vect 3 (List (Fin n)) vectTranspose {n = Z} [] = [[],[],[]] vectTranspose {n = (S len)} (x :: xs) with (natToFin len (S len)) …
marcosh
  • 8,780
  • 5
  • 44
  • 74
0
votes
1 answer

Idris proof of less than

I'm very new to Idris (and dependent types). I was trying to do write a program to check if a string is a palindrome of not. To do that, I decided to compute the length of the string, and compute q,r = (strlen `div` 2, strlen `mod` 2) and then…
0
votes
1 answer

How to rewrite term in type signature for proof in Idris?

Basically, I want to prove that either n - m or m - n is equal to zero in Recursive Arithmetic. To accomplish this I have been trying to use a rewrite ... in ... pattern without sucess. The following is the base code: data Natural = C | S…
Fabián Heredia Montiel
  • 1,687
  • 1
  • 16
  • 30
0
votes
2 answers

Does Idris have value types?

Does Idris have value types? The term "value type" is a bit ambiguous, but I don't know a better one. What I mean is: Is an array/struct of structs really always an array/struct of pointers (as in Java, and unlike C# and C++)?
MWB
  • 11,740
  • 6
  • 46
  • 91
0
votes
1 answer

Upgrading to Idris v 1.0 with Cabal?

Given: $idris -v 0.99 I would like to upgrade to version 1. However, I blindly tried to upgrade by running cabal install idris to see this output: $cabal install idris Resolving dependencies... All the requested packages are already…
Kevin Meredith
  • 41,036
  • 63
  • 209
  • 384