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
0 answers

remove downloads from cabal installation

I wanted to install Idris, so I first installed Haskell and then wrote cabal update and cabal install idris in the terminal. However, after downloading and installing lots of components, the installation finally failed on some packages. I then did…
Studentu
  • 1,375
  • 2
  • 10
  • 11
0
votes
1 answer

Understanding Argument Type

What's the meaning of this (a, b, c: Nat) argument in: g : (a, b, c: Nat) -> Int g (a,b,c) = 42 ? Evidently the first argument is a triple, i.e. 3-tuple.
Kevin Meredith
  • 41,036
  • 63
  • 209
  • 384
0
votes
1 answer

Idris interface syntax

I am trying to compile simple example of interface in Idris. interface Foo a where foo : a -> String But I keep getting this type-checking error: error: expected: "with", argument expression, function right hand side, implicit function…
user1747134
  • 2,374
  • 1
  • 19
  • 26
0
votes
1 answer

Idris simple proof with lists

I am trying to prove some simple things with idris but I am failing miserably. Here is my code module MyReverse %hide reverse %default total reverse : List a -> List a reverse [] = [] reverse (x :: xs) = reverse xs ++ [x] listEmptyAppend : (l :…
fakedrake
  • 6,528
  • 8
  • 41
  • 64
0
votes
2 answers

Is this recursive function not total, or is the compiler just unable to prove it? How to rewrite it as total?

When presented with the following code: module TotalityOrWhat %default total data Instruction = Jump Nat | Return Char | Error parse : List Char -> Instruction parse ('j' :: '1' :: _) = Jump 1 parse ('j' :: '2' :: _) = Jump 2 parse ('j' :: '3' ::…
Keith Pinson
  • 7,835
  • 7
  • 61
  • 104
0
votes
2 answers

Using types as first-class values in Scala?

In Idris, types are first-class values: FooType : (Type, Type) FooType = (Int, Int) fst FooType -- Int : Type I would like to use somehow this feature in Scala so that I can reuse type members over different methods: class Foo { type FooType =…
jarandaf
  • 4,297
  • 6
  • 38
  • 67
0
votes
1 answer

List Equality w/ `cong`

Following my other question, I tried to implement the actual exercise in Type-Driven Development with Idris for same_cons to prove that, given two equal lists, prepending the same element to each list results in two equal lists. Example: prove that…
Kevin Meredith
  • 41,036
  • 63
  • 209
  • 384
0
votes
2 answers

Define Equality of Lists Function

Type-Driven Development with Idris presents this exercise: same_cons : {xs : List a} -> {ys : List a} -> xs = ys -> x :: xs = x :: ys However, I attempted to implement it via: data EqList : (xs : List a) -> (ys : List a) -> Type where Same :…
Kevin Meredith
  • 41,036
  • 63
  • 209
  • 384
0
votes
1 answer

Data Type Encompassing Two Sum Types?

Given these 2 sum types: data Foo = A Int | B String data Bar = C Int | D String I'd like to define a function that returns Either (Foo or Bar) String. So, I attempted to make: data Higher = Foo | Bar But it failed to compile: *ADT> :r Type…
Kevin Meredith
  • 41,036
  • 63
  • 209
  • 384
0
votes
1 answer

Nested Pairs Exercise

Working through the ch6 exercises of Type-Driven Development with Idris, exercise 3 states: We could implement a vector as nested pairs, with the nesting calculated from the length. For example: TupleVect 0 ty = () TupleVect 1 ty = (ty,…
Kevin Meredith
  • 41,036
  • 63
  • 209
  • 384
0
votes
1 answer

Auto implicit arg stops working when type is given a name

While writing this answer, I noticed that while this works as expected: onlyModBy5 : (n : Nat) -> {auto prf : n `modNat` 5 = 0} -> Nat onlyModBy5 n = n foo : Nat foo = onlyModBy5 25 but as soon as I give a name to the property it stops…
Cactus
  • 27,075
  • 9
  • 69
  • 149
0
votes
1 answer

How to determine all sub-dimensions of a HVect?

I'd like to determine all sub-dimensions of a HVect as a HVect. Example: import Data.HVect myHVect : HVect [Int, String, List Nat] myHVect = [42, "text", [1, 2, 3]] subDimensions : HVect [ HVect [Int], HVect [Int, String], HVect [Int, String, List…
maiermic
  • 4,764
  • 6
  • 38
  • 77
0
votes
1 answer

Establish isomorphism between bounded naturals and naturals that satisfy bounds?

In Idris, can you establish an isomorphism between Fin n and (x ** So (x < n))? (I don't actually know Idris, so those types may not be valid. The general idea is that we have a data type that is guaranteed to be less than n by construction, and…
PyRulez
  • 10,513
  • 10
  • 42
  • 87
0
votes
2 answers

How can I print functions in Node.js the same way Firefox prints functions (namely giving a name)?

var fun1=function(){console.log('hello');} var fun2=fun1 console.log(fun2); The above code run in Firefox prints fun2. In Chrome it prints the function body, in Node.js it prints Function. Why is this difference? How can I get Firefox's behaviour…
jhegedus
  • 20,244
  • 16
  • 99
  • 167
0
votes
2 answers

Idris module name collision with 'base'

I have a module whose name ends with Data.List. Inside it i want to import module Data.List from the base library. module Foo.Data.List import Data.List If i invoke idris from folder Foo then compiler complains: [Foo]$ idris --check…
libeako
  • 2,324
  • 1
  • 16
  • 20
1 2 3
52
53