Repository: idris-lang/Idris-dev

Issue #600: ``Prelude.(!!): index too large'' error while type checking
Created: 2013-11-08T02:06:49Z
The following file, when loaded into the Idris repl, causes the error "Prelude.(!!): index too large"
import Data.Vect

total
finZEmpty : Fin Z -> a

fins : (n : Nat) -> (xs : Vect n (Fin n) ** ((x : Fin n) -> Elem x xs))
fins Z     = ([] ** finZEmpty)

Duplicate issue #738: ``Prelude.(!!): index too large'' error while type checking
Created: 2013-12-17T20:50:42Z
Maybe this is similar to #600
id.idr:
elimId : (a : Type) ->
         (a1 : a) ->
         (a2 : a) ->
         (m : (x : a) -> (y : a) -> x = y -> Type) ->
         (f : (x : a) -> m x x refl) ->
         (id : a1 = a2) ->
         m a1 a2 id
elimId _ x _ _ f refl = f x

tran : (a : Type) -> (b : a) -> (c : a) -> (d : a) ->  (e : b = c) ->  (f : c = d) ->  b = d
tran = \ a : Type , b : a , c : a , d : a , e : b = c =>
    elimId a b c (\ f : a , g : a , h : f = g => (i : a) ->  (j : g = i) ->  f = i)
                 (\ f : a , g : a , h : f = g =>  h) e d


type-checking:
$ idris id.idr 
     ____    __     _                                          
    /  _/___/ /____(_)____                                     
    / // __  / ___/ / ___/     Version 0.9.10.1
  _/ // /_/ / /  / (__  )      http://www.idris-lang.org/      
 /___/\__,_/_/  /_/____/       Type :? for help                

Type checking ./id.idr
idris: Prelude.(!!): index too large

Howerer, there is a workaround (extraction of lambda):
elimId : (a : Type) ->
         (a1 : a) ->
         (a2 : a) ->
         (m : (x : a) -> (y : a) -> x = y -> Type) ->
         (f : (x : a) -> m x x refl) ->
         (id : a1 = a2) ->
         m a1 a2 id
elimId _ x _ _ f refl = f x

m : (a : Type) -> (f : a) -> (g : a) -> (f = g) -> f = g
m = \ a : Type , f : a , g : a , h : f = g =>  h

tran : (a : Type) -> (b : a) -> (c : a) -> (d : a) ->  (e : b = c) ->  (f : c = d) ->  b = d
tran = \ a : Type , b : a , c : a , d : a , e : b = c =>
    elimId a b c (\ f : a , g : a , h : f = g => (i : a) ->  (j : g = i) ->  f = i)
                 (m a) e d

Closing comment (2013-12-17T20:53:56Z): Yes, I believe it is the same.
On 17 Dec 2013, at 20:50, Ilya Klyuchnikov notifications@github.com wrote:

Maybe this is similar to #600
id.idr:
elimId : (a : Type) ->
(a1 : a) ->
(a2 : a) ->
(m : (x : a) -> (y : a) -> x = y -> Type) ->
(f : (x : a) -> m x x refl) ->
(id : a1 = a2) ->
m a1 a2 id
elimId _ x _ _ f refl = f x
tran : (a : Type) -> (b : a) -> (c : a) -> (d : a) ->  (e : b = c) ->  (f : c = d) ->  b = d
tran = \ a : Type , b : a , c : a , d : a , e : b = c =>
elimId a b c (\ f : a , g : a , h : f = g => (i : a) ->  (j : g = i) ->  f = i)
(\ f : a , g : a , h : f = g =>  h) e d
type-checking:
$ idris id.idr
____    __     _
/  // /()___
/ // __  / / / /     Version 0.9.10.1
/ // // / /  / (  )      http://www.idris-lang.org/
//_,//  //___/       Type :? for help
Type checking ./id.idr
idris: Prelude.(!!): index too large
Howerer, there is a workaround (extraction of lambda):
elimId : (a : Type) ->
(a1 : a) ->
(a2 : a) ->
(m : (x : a) -> (y : a) -> x = y -> Type) ->
(f : (x : a) -> m x x refl) ->
(id : a1 = a2) ->
m a1 a2 id
elimId _ x _ _ f refl = f x
m : (a : Type) -> (f : a) -> (g : a) -> (f = g) -> f = g
m = \ a : Type , f : a , g : a , h : f = g =>  h
tran : (a : Type) -> (b : a) -> (c : a) -> (d : a) ->  (e : b = c) ->  (f : c = d) ->  b = d
tran = \ a : Type , b : a , c : a , d : a , e : b = c =>
elimId a b c (\ f : a , g : a , h : f = g => (i : a) ->  (j : g = i) ->  f = i)
(m a) e d
—
Reply to this email directly or view it on GitHub.