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

reading and writing at Idris

I am in my first steps of learing "Idris". I am using this tutorial: http://docs.idris-lang.org/en/latest/tutorial/starting.html I created file called "hello.idr". The content of the file is : module Main main : IO () main = putStrLn "Hello…
DBM
  • 71
  • 7
0
votes
1 answer

Polymorphic constant in a dependent type signature?

Say I'd like to define a type of a proof that some vector has a certain sum. I'd also like that proof to work for any Monoid type t. My first attempt was this: data HasSum : Monoid t => t -> Vect n t -> Type where EndNeutral : Monoid t => HasSum…
Sventimir
  • 1,996
  • 3
  • 14
  • 25
0
votes
1 answer

Define a data type inside an interface in Idris

I wish to create a class of types for which one can prove a certain element is positive or negative, or zero. I have created an interface: interface Signed t where data Positive : t -> Type data Negative : t -> type data IsZero : t ->…
Sventimir
  • 1,996
  • 3
  • 14
  • 25
0
votes
1 answer

Case expression in dependent type not working as expected in Idris

I am playing around porting small bits of PureScript code to Idris where dependent types could be applied and stumbled across a situation where using case inside a dependent type is not working. Since this is valid (simplified): data ValidInvoice3 :…
0dB
  • 675
  • 5
  • 13
0
votes
1 answer

Idris: reconstruct equality after pattern-matching

I'm deconstructing a list into head and tail but later I need a proof that they give me the original list back when combined: test: Bool -> String test b = let lst = the (List Nat) ?getListFromOtherFunction in case lst of Nil =>…
simpadjo
  • 3,947
  • 1
  • 13
  • 38
0
votes
0 answers

Stack code from TDD book: trying to remove code duplicates

Faced next problem while reading great Type Driven Development book and trying to implement some small modifications of tasks in it. module Main import Data.Vect %default total data Forever = More Forever partial forever : Forever forever = More…
Andrey
  • 712
  • 6
  • 16
0
votes
1 answer

Control.ST pure type

pure : (result : ty) -> STrans m ty (out_fn result) out_fn from http://docs.idris-lang.org/en/latest/st/state.html#strans-primitive-operations I'm not sure what (out_fn result) out_fn means. Is it about constraining out_fn to be a function of…
corazza
  • 31,222
  • 37
  • 115
  • 186
0
votes
1 answer

Data type that represents the proof that two functions are equivalent

I was trying to make a data type that represents that fact that two functions are equivalent. What does the error mean? Code: record FEq (f1 : a -> b) (f2 : a -> b) where constructor MkFEq unFEq : (x : a) -> (f1 x = f2 x) Error: Type…
michaelmesser
  • 3,601
  • 2
  • 19
  • 42
0
votes
1 answer

Why does 'neutral' not normalize to '[]' in the List monoid?

The following Idris definition typechecks with Idris 1.3.0: foo : (xs : List Nat) -> xs = ([] <+> xs) foo xs = Refl however, this doesn't: foo : (xs : List Nat) -> xs = (neutral <+> xs) foo xs = Refl giving the following type error: When checking…
Cactus
  • 27,075
  • 9
  • 69
  • 149
0
votes
0 answers

Hole with Delay in type. How to prove?

I was trying to prove that replicate1 works correctly by showing that all elements of replicate1 n x are x: all1 : (p : a -> Bool) -> List a -> Bool all1 p [] = True all1 p (x :: xs) = p x && all1 p xs replicate1 : (n: Nat) -> a -> List…
Andrey
  • 712
  • 6
  • 16
0
votes
1 answer

"rewriting did not change type" error for visually same types

I wrote a short function: swapMaybe : Monad m => Maybe (m a) -> m (Maybe a) swapMaybe Nothing = pure Nothing swapMaybe (Just x) = map Just x Then I tried to prove one of its properties: import Interfaces.Verified swapMaybePreservesMap :…
stop-cran
  • 4,229
  • 2
  • 30
  • 47
0
votes
1 answer

Complete proof that if last list element not in list, prepending will not be making it so

Having done exercise 9.1 of the book Type Driven Development with Idris I can not get one of my proofs to be complete. The exercise is to make the isLast function work. It should return a proof of that a value is the last value of a List. It works,…
Lodewijk Bogaards
  • 19,777
  • 3
  • 28
  • 52
0
votes
1 answer

How to understand SDecl in idris?

I am working on writing a backend for idris , the idris code (abbreviated) main = putStrLn "hello" generated this : (SLet (Loc 1) (SLet (Loc 1) (SConst "hello\n") (SOp LWriteStr [Loc 0,Loc 1])) (SCon Nothing 0…
doofin
  • 508
  • 2
  • 13
0
votes
1 answer

bind to abstract types for c struct with idris

I can not find how to treat this typedef struct TF_Status TF_Status; as abstract types and bind to that the c function is TF_Status* TF_NewStatus(); data TF_Status tfNewStatus : IO TF_Status tfNewStatus = foreign FFI_C "TF_NewStatus" (IO…
doofin
  • 508
  • 2
  • 13
0
votes
1 answer

How can I use a proof I've made in Idris to inform the compiler that my type signature is correct?

I have a function count in idris, defined as : count : Eq a => a -> Vect n a -> Nat count x [] = Z count x (y::ys) = with (x == y) | True = S (count x ys) | False = count x ys And a proof of the maximum value count can return: countLTELen : Eq…
Samuel Barr
  • 434
  • 4
  • 12