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
varDecl :: Type -> [String] -> StringSource
Takes a type and a list of variable names and declares them.
arrDecl :: Type -> [(String, Int)] -> StringSource
Takes a type and a list of array names and their sizes declares them.
varInit :: Show a => Type -> String -> a -> StringSource
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] -> StringSource
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] -> StringSource
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 -> StringSource
Add an include of a library
includeQuote :: String -> StringSource
Add an include of a header file
printfNewline :: String -> [String] -> StringSource
printf, with and without a newline (nl) character.