Created
June 13, 2014 13:52
-
-
Save fieldstrength/a504771921eb4c5874bf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- boilerplate functions | |
natToInt : Nat -> Int | |
natToInt Z = 0 | |
natToInt (S n) = 1 + (natToInt n) | |
natToString : Nat -> String | |
natToString n = show (natToInt n) | |
finToString : Fin n -> String | |
finToString f = natToString $ cast f {to = Nat} | |
pshow : Vect n (Fin m) -> String | |
pshow Nil = "" | |
pshow (f :: Nil) = (finToString f) | |
pshow (f :: rest) = (finToString f) ++ " " ++ (pshow rest) | |
allN : (n : Nat) -> Vect n (Fin n) | |
allN Z = Nil | |
allN (S n) = last :: (map weaken $ allN n) | |
-- applying in two steps works fine: | |
test1 : Vect 3 (Fin 3) | |
test1 = allN 3 | |
test2 : String | |
test2 = pshow test1 | |
-- applying in one step yields unexpected "incomplete term" error: | |
test3 : String | |
test3 = pshow $ allN 3 | |
{- | |
Type checking ./error.idr | |
error.idr:36:7:Incomplete term pshow (allN (fromInteger 3)) | |
Metavariables: Main.test3 | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment