How to rewrite a function body in Idris so that the type corresponds to the function signature and the whole thing compi
By : user2154371
Date : March 29 2020, 07:55 AM
will be helpful for those in need Just to add to the previous answer, one other possibility is to do the rewrite inline using the existing plusZeroRightNeutral lemma from the library: code :
foo: Vect n String > Vect n String
foo {n} xs = let xs' : Vect (n + 0) String
= rewrite (plusZeroRightNeutral n) in xs in
take n xs'
take : (n : Nat) > Vect (n + m) a > Vect n a

Idris  Can't evaluate function application in type
By : timtimsheroo
Date : March 29 2020, 07:55 AM
will help you Apparently this issue is solved now after updating to Idris 0.12. Haven't changed anything but it typechecks now.

Type of anonymous identity function in Idris
By : Thomas Karlson
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Type inference, in general, is undecidable for dependent types, see e.g. the answers to this CS.SE question. In Idris, you can get away with not specifying types for some terms, but not all. If you add your definition to an .idr file and try to load it, like code :
myId = \x => x
myId : _
myId = \x => x
myId : _ > _
myId = \x => x
myId : {a : _} > a > a
myId = \x => x
myId : a > a
myId = \x => x

Views in Idris  Listing 10.5 of TypeDriven Development in Idris book
By : xxdzyyh
Date : March 29 2020, 07:55 AM
wish helps you The reason for this error message is that Idris does not see that xs = lhs ++ rhs, you have to convince Idris. First of all, let's prove the above fact as a separate lemma: code :
total
takeDropAppend : (n : Nat) > (xs : List ty) > xs = List.take n xs ++ List.drop n xs
takeDropAppend Z _ = Refl
takeDropAppend (S n) [] = Refl
takeDropAppend (S n) (x :: xs) = cong $ takeDropAppend n xs
total
splitList : (xs: List ty) > SplitList xs
splitList [ ] = Null
splitList [x] = Singleton
splitList xs =
let
mid = divNatNZ (List.length xs) 2 SIsNotZ
in
rewrite takeDropAppend mid xs in
Pair (List.take mid xs) (List.drop mid xs)

'half' function type signature in Idris
By : Timdows
Date : March 29 2020, 07:55 AM
will be helpful for those in need What you want is to express that half n is some Natural number k such that n = k + k holds. The way to do it is by using a sigma type, i.e. a dependent pair of a number k and a proof n = k + k (it's a dependent pair because the type of the second coordinate, n = k + k depends on the value of the first coordinate, k). The Idris standard library defines DPair for depedent pairs, including some syntax sugar allowing you to write

