Getting Started
-
Build the compiler
Follow Building to build
kuracfrom source. You need CMake and LLVM. -
Write a UI
Create
counter.kui:type State = { count: Int }type Message = Clickfn init(): State => { count: 0 }fn update(msg: Message, state: State): State =>match msg {Click => { count: state.count + 1 },}fn view(state: State): Content =>#button(on-click: Click) {#text("Clicked")#text(state.count)}Only
viewis required. A static UI can be a singleviewfunction. See The MVU Model for the rules. -
Compile it
Inspect the generated LLVM IR:
Terminal window kurac counter.kui --emit-llvmOr produce a native object file:
Terminal window kurac counter.kui --emit-obj counter.o -
Try a function
kuraccan JIT a single function and run it, which is handy for testing logic:Terminal window kurac counter.kui --run initArguments after the function name are parsed as numbers, units (
10px), bools,none, or strings. The command line can only pass scalars, so functions that take records can’t be called this way.
Compiler options
Section titled “Compiler options”kurac <file> [<c-source>.c...] [options]| Option | Purpose |
|---|---|
--emit-llvm |
Print the LLVM IR for the module |
--emit-obj <file.o> |
Write a native object file |
--emit-header <file.h> |
Write the C header for extern fns that have bodies |
--no-opt |
Skip LLVM optimization |
--run <fn> [args...] |
JIT the module and call fn; everything after the name is an argument |
-I<dir>, -D<name> |
Include paths and defines for headers a program uses |
-L<dir>, -l<lib> |
Libraries the program calls (for --run) |
file.c |
Compile a C file into the module so LLVM can inline into it |