Last active
October 13, 2018 04:03
-
-
Save mukeshtiwari/fdcc168f530e87f6237240fbfa2cb4a1 to your computer and use it in GitHub Desktop.
This file contains 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
printfType : List Char -> Type | |
printfType [] = String | |
printfType ('%' :: 'd' :: rest) = Int -> printfType rest | |
printfType ('%' :: 's' :: rest) = String -> printfType rest | |
printfType (c :: rest) = printfType rest | |
{- construct value level function -} | |
printfValue : (xs : List Char) -> String -> printfType xs | |
printfValue [] acc = acc | |
printfValue ('%' :: 'd' :: rest) acc = \x => printfValue rest (acc ++ show x) | |
printfValue ('%' :: 's' :: rest) acc = \x => printfValue rest (acc ++ x) | |
printfValue (c :: rest) acc = printfValue rest (acc ++ singleton c) | |
- + Errors (1) | |
`-- Printf.idr line 31 col 30: | |
When checking right hand side of printfValue with expected type | |
printfType (c :: rest) | |
Type mismatch between | |
printfType rest (Type of printfValue rest (acc ++ singleton c)) | |
and | |
printfType (c :: rest) (Expected type) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment