Language.Copilot.AdHocC
Description
Helper functions for writing free-form C code.
- varDecl :: Type -> [String] -> String
- arrDecl :: Type -> [(String, Int)] -> String
- varInit :: Show a => Type -> String -> a -> String
- arrayInit :: Show a => Type -> String -> [a] -> String
- funcDecl :: Maybe Type -> String -> [Type] -> String
- includeBracket :: String -> String
- includeQuote :: String -> String
- printf :: String -> [String] -> String
- printfNewline :: String -> [String] -> String
Documentation
arrDecl :: Type -> [(String, Int)] -> String
Takes a type and a list of array names and their sizes declares them.
varInit :: Show a => Type -> String -> a -> String
Takes a type and a variable and initializes it. It is YOUR responsibility
to ensure that val is of type t.
arrayInit :: Show a => Type -> String -> [a] -> String
Takes a type and an array and initializes it. It is YOUR responsibility to
ensure that vals is of type t.
funcDecl :: Maybe Type -> String -> [Type] -> String
Declare function prototypes, given a return type, a function name, and a
| list of argument types. Use Nothing for a return type of void.
includeBracket :: String -> String
Add an include of a library
includeQuote :: String -> String
Add an include of a header file
printfNewline :: String -> [String] -> String
printf, with and without a newline (nl) character.