Kip (meaning "grammatical mood" in Turkish) is an experimental programming language that uses Turkish grammatical cases as part of its type system. It demonstrates how natural language morphology—specifically Turkish noun cases and vowel harmony—can be integrated into programming language design.
This is a research/educational project exploring the intersection of linguistics and type theory, not a production programming language.
There is also a tutorial in Turkish and a tutorial in English that explains how to write Kip programs.
Note
Kip is experimental. Expect changes in syntax and behavior over time.
For you to get a taste of what Kip looks like, here is an example program that reads a name and prints a greeting:
selamlamak,
isim olarak okuyup,
("Merhaba "yla ismin birleşimini) yazmaktır.
selamlamak.
- Language Features
- Installation
- WASM Playground
- Bytecode Cache
- Project Structure
- Testing
- Morphological Analysis
- License
Kip uses Turkish noun cases (ismin halleri) to determine argument relationships in function calls:
| Case | Turkish Name | Suffix | Example |
|---|---|---|---|
| Nominative | Yalın hal | (none) | defter |
| Accusative | -i hali | -i, -ı, -u, -ü | sayıyı |
| Dative | -e hali | -e, -a | sayıya |
| Locative | -de hali | -de, -da, -te, -ta | listede |
| Ablative | -den hali | -den, -dan, -ten, -tan | listeden |
| Genitive | Tamlayan eki | -in, -ın, -un, -ün | sayının |
| Instrumental | -le eki | -le, -la, ile | sayıyla |
| Possessive (3s) | Tamlanan eki | -i, -ı, -u, -ü, -si, -sı | ardılı |
Because Turkish cases mark grammatical relationships explicitly, Kip allows flexible argument ordering. These two calls are equivalent:
(5'le 3'ün farkını) yaz.
(3'ün 5'le farkını) yaz.
As long as arguments have different case suffixes or different types, Kip can determine which argument is which.
Define algebraic data types with Turkish syntax:
Bir doğruluk ya doğru ya da yanlış olabilir.
Bir trafik-ışığı
ya kırmızı
ya sarı
ya da yeşil
olabilir.
Type variables are supported for generic data structures:
Bir (öğe listesi)
ya boş
ya da bir öğenin bir öğe listesine eki
olabilir.
Pattern match using the conditional suffix -sa/-se:
(bu doğruluğun) tersi,
bu doğruysa, yanlış,
yanlışsa, doğrudur.
Supports nested pattern matching, binders, and wildcard patterns (değilse):
(bu trafik-ışığının) eylemi,
bu kırmızıysa, "Dur",
sarıysa, "Hazırlan",
yeşilse, "Geç"tir.
Define named constants with a definition sentence:
merhaba, "Merhaba"'dır.
dünya, "Dünya"'dır.
Sequencing with -ip/-ıp/-up/-üp suffixes and binding with olarak:
selamlamak,
isim olarak okuyup,
("Merhaba "yla ismin birleşimini) yazmaktır.
Integers (tam-sayı):
- Arithmetic:
toplamı,farkı,çarpımı - Comparison:
eşitliği,küçüklüğü,büyüklüğü - Other:
faktöriyeli
Strings (dizge):
uzunluğu- lengthbirleşimi- concatenationtam-sayı-hali- parse as integer
I/O:
yazmak/yaz- print to stdoutokumak/oku- read from stdin
(* This is a comment *)
5'i yaz. (* Integer literal with case suffix *)
"merhaba"'yı yaz. (* String literal with case suffix *)
3.14'ü yaz. (* Floating-point literal with case suffix *)
-
Foma - finite-state morphology toolkit
- macOS:
brew install foma - Debian/Ubuntu:
apt install foma libfoma-dev - Fedora:
dnf install foma foma-devel
- macOS:
-
Stack - Haskell build tool
- See haskellstack.org
Tip
If you only want to explore the language, you can start with stack exec kip after a successful build.
Clone this repository, then:
# Quick install (macOS/Linux)
chmod +x install.sh
./install.sh
# Or manual build
stack build
# Install to PATH
stack installThe TRmorph transducer is bundled at vendor/trmorph.fst.
If you have installed to PATH, you can do:
# Start REPL
kip
# Execute a file
kip --exec path/to/file.kip
# Generate JavaScript
kip --codegen js path/to/file.kipkip-lsp speaks LSP over stdio. You can run it directly for editor integration:
stack exec kip-lspMake sure kip-lsp is on your PATH, or configure your editor to call the
absolute path from stack exec -- which kip-lsp.
VS Code (generic LSP extension):
{
"languageServerExecutable": "kip-lsp",
"languageServerArgs": []
}Neovim (init.lua):
vim.lsp.start({
name = "kip-lsp",
cmd = { "kip-lsp" },
root_dir = vim.fn.getcwd(),
})Emacs (eglot):
(add-to-list 'eglot-server-programs '(kip-mode . ("kip-lsp")))A browser playground can be built from source under playground/. It compiles the
non-interactive runner (kip-playground) to wasm32-wasi and ships a small
HTML/JS harness that runs Kip in the browser.
Note
The playground/dist/ directory is not included in the repository. You must build it locally following the instructions below.
See playground/README.md for prerequisites, toolchain setup, and build steps.
Kip stores a cached, type-checked version of each .kip file in a sibling .iz file. When you run a file again, Kip will reuse the .iz cache if both the source and its loaded dependencies are unchanged.
If you want to force a fresh parse and type-check, delete the .iz file next to the source.
Important
.iz files include a compiler hash. If the compiler changes, the cache is invalidated automatically.
app/
├── Main.hs - CLI entry point
└── Playground.hs - WASM playground runner
src/
├── Kip/
│ ├── AST.hs - Abstract syntax tree
│ ├── Cache.hs - .iz cache handling
│ ├── Codegen/
│ │ └── JS.hs - JavaScript codegen
│ ├── Eval.hs - Interpreter
│ ├── Parser.hs - Parser
│ ├── Render.hs - Pretty-printing with morphological inflection
│ ├── Runner.hs - CLI runner utilities
│ └── TypeCheck.hs - Type checker validating grammatical case usage
└── Language/
└── Foma.hs - Haskell bindings to Foma via FFI
lib/
├── giriş.kip - Prelude module loaded by default
├── temel.kip - Core types
├── temel-doğruluk.kip - Boolean functions
├── temel-dizge.kip - String functions
├── temel-etki.kip - I/O primitives
├── temel-liste.kip - List functions
├── temel-ondalık-sayı.kip - Floating-point functions
├── temel-tam-sayı.kip - Integer functions
└── *.iz - Generated bytecode caches (if built)
playground/
└── README.md - WASM playground build notes
tests/
├── succeed/ - Passing golden tests (.kip + .out + optional .in)
├── fail/ - Failing golden tests (.kip + .err)
└── repl/ - REPL interaction tests (.repl)
c/
├── morphology.c - Foma glue (C)
└── morphology.h - Foma glue headers
vendor/
└── trmorph.fst - TRmorph transducer
stack testTests are in tests/succeed/ (expected to pass) and tests/fail/ (expected to fail).
The test suite also runs a basic kip-lsp roundtrip if kip-lsp is on PATH
or KIP_LSP_BIN is set.
Kip uses TRmorph for Turkish morphological analysis. When a word has multiple possible parses (e.g., "takası" could be "taka + possessive" or "takas + accusative"), Kip carries all candidates through parsing and resolves ambiguity during type checking.
For intentionally ambiguous words, use an apostrophe to force a specific parse: taka'sı vs takas'ı.
See LICENSE file.