Questions tagged [idris2]
27 questions
0
votes
1 answer
How to use the result of a depedent pair?
I am learning dependent pairs in idris and couldn't understand how one can use it. For example, if I filter a Data.List, I get back a Data.List, which you I do sum or other computations on.
sum $ filter (< 3) [1,2,3,4]
3
But if I filter a…

thor
- 21,418
- 31
- 87
- 173
0
votes
0 answers
How to fix an inaccessible variable in idris2?
I am having trouble to make a short idris2 code from the summer school course SPLV20 work. The error is at the last line:
module Text.Token
%default total
||| For a type `kind`, specify a way of converting the recognised
||| string into a value.…

thor
- 21,418
- 31
- 87
- 173
0
votes
0 answers
Why isn't this variable unknown in the type definition?
import Data.Vect
data NamedVect : Type -> (names : Vect n String) -> Type where
Nil : NamedVect a []
(::) : a -> NamedVect a ss -> NamedVect a (foo :: ss)
aa : NamedVect Nat ["name", "age"]
aa = [1,3]
I'm interested in the foo variable. Where…

Gqqnbig
- 5,845
- 10
- 45
- 86
0
votes
1 answer
What are the builddir and outputdir and why are they generating a "File Not Found" error?
The Goal: package an executable "Hello, world" program in Idris2
I'm working from the docs, which gives descriptions of the package fields but sadly doesn't provide any examples.
The issue: "File Not Found" compilation errors on the builddir and…

Eleanor Holley
- 691
- 1
- 7
- 27
0
votes
1 answer
How does Fin "know" not to go past its type bound?
How does Fin actually work?
data Nat = Z | S Nat
data Fin : (n : Nat) -> Type where
FZ : Fin (S k)
FS : Fin k -> Fin (S k)
Where does k come from?
Why isn't FZ always the value of (n: Nat) + 1?
How does Fin "know" not to exceed its type…
0
votes
1 answer
Why idris2 can't proof that div 1 2 < 1 = True?
When I write:
div_1_2_lower_than_1 : div (S Z) 2 < (S Z) = True
div_1_2_lower_than_1 = Refl
I get error:
While processing right hand side of div_1_2_lower_than_1. Can't solve constraint
between: True and compare (1 `div` 2) 1 == LT.
Meanwhile when…

N0lim
- 65
- 7
0
votes
1 answer
How do I read all of standard input in Idris2?
I'm trying to figure out how to do something very simple: read all of standard input into a string (or a list of strings would be fine too).
Prelude has getLine : HasIO io => io String, which can give me one line, but it doesn't give me a way to…

Tomas Aschan
- 58,548
- 56
- 243
- 402
0
votes
1 answer
Check length of a tuple by pattern matching
I want to learn idris by writing a length function that checks the length of a tuple. I leanred a tuple is made by the MkPair constructor so I try to do pattern matching.
length : {t2:_} -> Pair t1 t2 -> Nat
length (MkPair a b) = case b of
…

Gqqnbig
- 5,845
- 10
- 45
- 86
0
votes
1 answer
How many times does a type function run, can you prove?
People say a dependent type language is slow in type checking so I think it is slow in running type functions.
Use the classic example on https://idris2.readthedocs.io/en/latest/tutorial/typesfuns.html
isSingleton : Bool -> Type
isSingleton True =…

Gqqnbig
- 5,845
- 10
- 45
- 86
0
votes
1 answer
Can I print something in the middle of a function?
One example code on https://idris2.readthedocs.io/en/latest/tutorial/typesfuns.html says isSingleton returns Nat when the parameter is True, and returns a list when the parameter is False.
isSingleton : Bool -> Type
isSingleton True =…

Gqqnbig
- 5,845
- 10
- 45
- 86
0
votes
1 answer
Idris2: Nested WITH clause
My Code
My piece of code, i.e.:
equal_suffix: Eq a => List a -> List a -> List a
equal_suffix u v with (snocList u)
equal_suffix _ _ | Empty = []
equal_suffix _ v | (Snoc x xs snx) with (snocList v)
equal_suffix _ _ | (Snoc x xs snx)…

Clément Dato
- 283
- 2
- 7
0
votes
1 answer
Returning a dependent pair from a foreign function
I have the following Chez support file:
(define list-copy-with-length (xs)
(cons (length xs) (list-copy xs)))
and I have this Idris file:
%foreign "scheme,chez:list-copy-with-length"
prim__listToVect : List t -> (Nat, Vect n t)
listToVect : List…

shadowtalker
- 12,529
- 3
- 53
- 96