Skip to content

Commit 914b99e

Browse files
committed
[ re #155 ] Make the type of vlength more precise
1 parent d25143d commit 914b99e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

test/CompileTo.agda

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11

22
open import Haskell.Prelude
3+
open import Haskell.Extra.Refinement
4+
open import Haskell.Law.Equality
35

46
private variable
57
@0 n : Nat
@@ -32,13 +34,15 @@ llength (x ∷ xs) = 1 + llength xs
3234

3335
{-# COMPILE AGDA2HS llength #-}
3436

35-
vlength : Vec a n Nat
36-
vlength [] = 0
37-
vlength (x ∷ xs) = 1 + vlength xs
37+
vlength : Vec a n ∃ Nat (_≡ n)
38+
vlength [] = 0 ⟨ refl ⟩
39+
vlength (x ∷ xs) =
40+
let n ⟨ eq ⟩ = vlength xs
41+
in (1 + n) ⟨ cong suc eq ⟩
3842

3943
{-# COMPILE AGDA2HS vlength to llength #-}
4044

41-
test3 : Nat
45+
test3 : Nat (_≡ 3)
4246
test3 = vlength test1
4347

4448
{-# COMPILE AGDA2HS test3 #-}

0 commit comments

Comments
 (0)