Skip to content

Instantly share code, notes, and snippets.

@mukeshtiwari
Last active October 13, 2018 04:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mukeshtiwari/fdcc168f530e87f6237240fbfa2cb4a1 to your computer and use it in GitHub Desktop.
Save mukeshtiwari/fdcc168f530e87f6237240fbfa2cb4a1 to your computer and use it in GitHub Desktop.
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