Questions tagged [idris2]
27 questions
4
votes
1 answer
Can I avoid lower-case global variables being shadowed in types?
The following code compiles okay in Idris2:
C : Nat
C = 2
claim : C = 2
claim = Refl
but it fails if C is not capitalized:
c : Nat
c = 2
claim : c = 2
claim = Refl
The error message is
Warning: We are about to implicitly bind the following…

haskell looks great
- 415
- 2
- 8
3
votes
1 answer
Idris totality check
I am compiling the following simple program using Idris2.
import Data.Fin
%default total
negate : {k:_} -> Fin k -> Fin k
subt : {k:_} -> Fin k -> Fin k -> Fin k
add : {k:_} -> Fin k -> Fin k -> Fin k
mult : {k:_} -> Fin k -> Fin k -> Fin k
mult…

haskell looks great
- 415
- 2
- 8
3
votes
2 answers
What does the 0 or 1 before a parameter name mean in Idris?
I've seen it here and there in Idris source code, but I have yet to find an explanation for what it means. The closest I've gotten is finding that it's called RigCount in the syntax reference. But what is it?
test : (0 a : b) -> b
test x = x
-- …

Aron
- 8,696
- 6
- 33
- 59
2
votes
0 answers
How should I sum doubles in Idris?
I don't understand why the following does not work:
Main> 2.1 + 2.3
Error: Can't find an implementation for FromDouble Integer.
(Interactive):1:1--1:4
1 | 2.1 + 2.3
^^^
It works with integers, and if I understand the docs correctly, it…

lxnv
- 41
- 5
2
votes
0 answers
Idris 2 analog to Agda's `rewrite` that also changes types of bindings in the environment
Suppose I have a theorem
foo : (n : _) -> (f : Fin (n + 0)) -> ...
foo n f = ?goal
and it'd really benefit me if I could use f in contexts where Fin n is expected (and I really mean the precise term f instead of, say, replace (plusZeroRightNeutral…

0xd34df00d
- 1,496
- 1
- 8
- 17
2
votes
1 answer
How to deal with "Error: Multiple solutions found"?
I'm trying to build a set datatype.
mutual
data Set : Type -> Type where
Nil : Eq a => Set a
(::) : Eq a => (x : a) -> (s : Set a) -> {auto _ : contains x s = False} -> Set a
contains : Eq a => a -> Set a -> Bool
contains x [] =…

magras
- 1,709
- 21
- 32
2
votes
1 answer
How to use interfaces with parameterized tuple?
I have Coord function that transforms an n-dimensional size to the type of coordinates bounded by given size: Coord [2,3] = (Fin 2, Fin 3).
import Data.Fin
import Data.List
Size : Type
Size = List Nat
Coord : Size -> Type
Coord [] = ()
Coord s@(_…

magras
- 1,709
- 21
- 32
2
votes
1 answer
How to implement `Show` interface for parameterized tuple?
I have Coord function that transforms an n-dimensional size to the type of coordinates bounded by given size: Coord [2,3] = (Fin 2, Fin 3).
import Data.Fin
import Data.List
Size : Type
Size = List Nat
Coord : Size -> Type
Coord [] = ()
Coord s@(_…

magras
- 1,709
- 21
- 32
2
votes
0 answers
Main.case block in case block in _ is not accessible in this context
Walking through the format string example in the TDD of Idris2, and trying to do my own version of a format string. Here is what has worked:
data ShowableFmt = NatFmt | CharFmt | DoubleFmt
data CallableFmt = ShwFmt ShowableFmt | StrFmt
data Fmt =…

Clément Dato
- 283
- 2
- 7
2
votes
2 answers
Importing from the contrib library fails
I'm following the TDD book in Idris 2, and the online documentation gives the following advice:
For the VList view in the exercise 4 after Chapter 10-2 import Data.List.Views.Extra from contrib library.
So I put this import in a source file…

MB-F
- 22,770
- 4
- 61
- 116
1
vote
0 answers
How to write a pure function in idris2 FFI?
The idris2 has the following example for FFI, which adds two integers in C:
#include
int add(int x, int y) {
return x+y;
}
(small.c)
I followed the steps, and after linking:
gcc -shared smallc.c -o libsmall.so
and indeed the foreign…

thor
- 21,418
- 31
- 87
- 173
1
vote
0 answers
function with no parameter and the main function?
Book "Type-driven Development with Idris" page 52 has
2.5 Summary ...
Function types have one or more input types and one output type.
The entry point to an Idris program is the main function, which must have type IO (), and be defined in the…

Gqqnbig
- 5,845
- 10
- 45
- 86
1
vote
1 answer
Can we express () in terms of a Record in Idris?
Can we express () i.e Unit type in terms of a Record in Idris ?

Rocky
- 13
- 2
1
vote
1 answer
Why does Idris think my type parameter k is of type Type?
Sorry I couldn't think of a less confusing way to put this.
I'm trying to build something like a map that can be safely accessed without returning a maybe, because all of its keys are contained in its type and querying for a key that isn't contained…

Aron
- 8,696
- 6
- 33
- 59
0
votes
0 answers
Updating a dependently typed field without updating what it depends on
I'd like to use record update syntax to update a dependently-typed field without also changing the field it depends on. So I'd like to have Idris 2 evaluate the other field, and realize everything is kosher. Is this doable?
Here's a concrete minimal…

Cactus
- 27,075
- 9
- 69
- 149