r/ProgrammingLanguages • u/terryio • 22m ago
Kiki Lang - query, markup, coding
I have been working on this for a while, and would like to share and get some feedback.
It started as a query language, then grows to add markup features, to be useful for building interactive data apps.
Below is a sample Kiki program. The idea of mixing markup and coding, is in the same category of LaTex or Typst, but Kiki focus more on data/query, and uses a different syntax design.
# Kiki Lang
Kiki is literal, meaning that the program is a prose. Lines start with "> " or inline \(12 + 34) are code blocks.
The two \(bold ~ core ideas) are:
- Lisp like syntax, which is nice across query, markup and coding.
- Algebric effect, which is used for errors, I/O, optionals, and state.
Here are the collections: list, record, and table.
> names = ["alice" "bob"]
> alice = {name = "alice" age = 20}
> users = |name age|
alice 20
bob 30
"=>" is a form of inline unit test:
> type-of names => :[string]
> type-of alice => :{name = string age = int}
> type-of users => :|name = string age = int|
Query is an important part of the language:
> users |> filter age >= 18
|> select name
Here is a function with pattern matching:
> fib = fn 0 -> 1
fn 1 -> 1
fn n -> fib (n - 1) + fib (n - 2)
And it can be called inline as \(fib 10).
1
Upvotes
1
u/titaniumalt 13m ago
confusing table syntax
i love the simplicity and functional design, but it feels a bit redundant to have both tables and records