{"id":27891790,"url":"https://github.com/mieszkosabo/tartak","last_synced_at":"2026-03-09T03:31:18.657Z","repository":{"id":251618021,"uuid":"784301447","full_name":"mieszkosabo/tartak","owner":"mieszkosabo","description":"Tartak is a functional programming language that compiles to TypeScript types.","archived":false,"fork":false,"pushed_at":"2024-08-04T12:35:21.000Z","size":227,"stargazers_count":118,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-07T23:42:15.335Z","etag":null,"topics":["functional-programming","programing-language","type-level","type-level-programming","types","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mieszkosabo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-09T15:25:21.000Z","updated_at":"2025-09-01T02:28:04.000Z","dependencies_parsed_at":"2024-08-04T15:46:45.669Z","dependency_job_id":null,"html_url":"https://github.com/mieszkosabo/tartak","commit_stats":null,"previous_names":["mieszkosabo/tartak"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mieszkosabo/tartak","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mieszkosabo%2Ftartak","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mieszkosabo%2Ftartak/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mieszkosabo%2Ftartak/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mieszkosabo%2Ftartak/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mieszkosabo","download_url":"https://codeload.github.com/mieszkosabo/tartak/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mieszkosabo%2Ftartak/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30281486,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T02:57:19.223Z","status":"ssl_error","status_checked_at":"2026-03-09T02:56:26.373Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["functional-programming","programing-language","type-level","type-level-programming","types","typescript"],"created_at":"2025-05-05T12:12:06.670Z","updated_at":"2026-03-09T03:31:18.456Z","avatar_url":"https://github.com/mieszkosabo.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![tartak logo](./assets/TARTAK_LOGO.png)\n\n# Tartak\n\nTartak is a functional programming language that compiles to **TypeScript types**.\n\nMy goal was to create a language that's not just a syntax sugar over TypeScript types, but a language that's as close to any general purpose programming language as possible.\n\nTartak uses [hotscript](https://github.com/gvergnaud/hotscript), [ts-arithmetic](https://github.com/arielhs/ts-arithmetic) and many other tricks to make it happen.\n\n🔔 Keep in mind that this project is a work in progress, may contain bugs and missing features.\nAlso, see the [ROADMAP](#ROADMAP) section for planned features.\nFeel free to request features or report bugs with GitHub issues.\n\n## Feature highlights:\n\n- first-class functions (closures, functions returning functions, partial application, etc.)\n- support for arithmetic, relational and logical operators\n- built-in test sections a la Rust\n- pattern matching\n\n## Quick demo\n\n```ts\n// file: parseRoute.tartak\n\n// exported types will be available for you to import from compiled files\n// to distinguish between objects ({}) and blocks, blocks have a colon before the opening brace (:{})\nexport type parseRoute = (route: string) =\u003e :{\n  // assign computations to variables like this\n  let parts = route.split(\"/\"); // -\u003e [\"users\", \"\u003cid:string\u003e\", \"posts\", \"\u003cindex:number\u003e\"]\n\n  // last expression is the return value, like in Rust\n  parts\n    // method chaining!\n    .filter((part) =\u003e part.startsWith(\"\u003c\")) // -\u003e [\"\u003cid:string\u003e\", \"\u003cindex:number\u003e\"]\n    .map((part) =\u003e match part {\n      // infer subparts of the expression during pattern matching\n      `\u003c${infer name}:${infer ty}\u003e` -\u003e [name, ty]\n    }) // -\u003e [[\"id\", \"string\"], [\"index\", \"number\"]]\n    .toUnion() // -\u003e [\"id\", \"string\"] | [\"index\", \"number\"]\n    .fromEntries() // -\u003e { id: \"string\"; index: \"number\" }\n    .mapValues((ty) =\u003e match ty {\n      \"string\" -\u003e string,\n      \"number\" -\u003e number\n    }) // -\u003e { id: string; index: number }\n}\n\ntype params = parseRoute(\"/users/\u003cid:string\u003e/posts/\u003cindex:number\u003e\")\n//   ^?\n//    { id: string; index: number; }\n\n\n// Add tests alongside your code\n#[test] :{\n  AssertEqual(\n    parseRoute(\"/users/\u003cid:string\u003e/posts/\u003cindex:number\u003e\"),\n    { id: string, index: number }\n  )\n  AssertEqual(\n    parseRoute(\"/users/noParams\"),\n    {}\n  )\n}\n\n```\n\nThen, compile the file with:\n\n```bash\nnpx tartak parseRoute.tartak\n```\n\nThis will generate a `parseRoute.tartak.ts` file that exports `parseRoute` type, which can be imported and used like this:\n\n```ts\nimport { parseRoute } from \"./routeParser.tartak\";\n\ndeclare function redirect\u003cRoute extends string\u003e(\n  route: Route,\n  params: parseRoute\u003cRoute\u003e\n): void;\n\nredirect(\"/api/v1/user/\u003cid:string\u003e\", {\n  id: \"123\", // OK\n});\n\nredirect(\"/api/v1/user/\u003cid:string\u003e\", {\n  id: 123, // Error: Type 'number' is not assignable to type 'string'\n});\n\nredirect(\"/api/v1/user/\u003cid:string\u003e\", {\n  hello: \"123\", // Error: Object literal may only specify known properties, and hello does not exist in type:\n});\n```\n\n## Getting started\n\nFirst, install Tartak with your favorite package manager:\n\n```bash\nnpm i -D tartak\nyarn add -D tartak\npnpm add -D tartak\nbun add -D tartak\n```\n\nThen, create a file with the `.tartak` extension and start writing your code. You can place `.tartak` files anywhere in your project.\nFor example:\n\n```tartak\n// hello.tartak\n\nexport type greet = (name: string) =\u003e `hello ${name}`;\n```\n\nTo compile your code into a TypeScript file, run:\n\n```bash\n# This will recursively look for all .tartak files starting from the current directory and compile them to corresponding *.tartak.ts files.\nnpx tartak\n\n# Or, you can specify the path to the file you want to compile\nnpx tartak hello.tartak\n\n# Or, you can watch for changes\nnpx tartak --watch\n```\n\n## ROADMAP\n\n- [ ] readonly\n- [ ] optional parameters\n- [ ] language server?\n- [x] optional object properties\n- [x] cli: --watch flag\n- [x] imports/exports\n- [x] closures\n- [x] partial application\n- [x] arithmetic operators\n  - [x] - (subtraction)\n  - [x] - (negation)\n  - [x] `+`\n  - [x] /\n  - [x] `**` (power)\n  - [x] % (mod)\n- [x] relational and logical operators\n  - [x] ==\n  - [x] !=\n  - [x] \u003c\n  - [x] \u003c=\n  - [x] \u003e\n  - [x] `\u003e=`\n  - [x] \u0026\u0026 (logical and)\n  - [x] || (logical or)\n  - [x] ! (logical not)\n- [ ] string methods\n  - [x] .length\n  - [x] .trimLeft\n  - [x] .trimRight\n  - [x] .trim\n  - [x] .replace\n  - [ ] .slice\n  - [x] .split\n  - [x] .repeat\n  - [x] .startsWith\n  - [x] .endsWith\n  - [x] .toTuple\n  - [x] .toNumber\n  - [x] .toString\n  - [x] .stringsPrepend\n  - [x] .stringsAppend\n  - [x] .uppercase\n  - [x] .lowercase\n  - [x] .capitalize\n  - [x] .uncapitalize\n  - [x] .snakeCase\n  - [x] .camelCase\n  - [x] .kebabCase\n  - [x] .compare\n  - [x] .lessThan\n  - [x] .lessThanOrEqual\n  - [x] .greaterThan\n  - [x] .greaterThanOrEqual\n- [x] number methods\n  - [x] .abs\n- [ ] object methods\n  - [ ] .readonly\n  - [ ] .mutable\n  - [ ] .required\n  - [ ] .partial\n  - [ ] .readonlyDeep\n  - [ ] .mutableDeep\n  - [ ] .requiredDeep\n  - [ ] .partialDeep\n  - [ ] .update\n  - [ ] .keys\n  - [ ] .values\n  - [ ] .allPath\n  - [ ] .get\n  - [ ] .fromEntries\n  - [ ] .entries\n  - [ ] .mapValues\n  - [ ] .mapKeys\n  - [ ] .assign\n  - [ ] .pick\n  - [ ] .pickBy\n  - [ ] .omit\n  - [ ] .omitBy\n  - [ ] .objectCamelCase\n  - [ ] .objectCamelCaseDeep\n  - [ ] .objectSnakeCase\n  - [ ] .objectSnakeCaseDeep\n  - [ ] .objectKebabCase\n  - [ ] .objectKebabCaseDeep\n- [ ] union methods\n  - [ ] .mapUnion\n  - [ ] .extract\n  - [ ] .extractBy\n  - [ ] .exclude\n  - [ ] .excludeBy\n  - [ ] .unionNonNullable\n  - [ ] .unionToTuple\n  - [ ] .unionToIntersection\n- [x] tuple methods\n  - [x] .partition\n  - [x] .isEmpty\n  - [x] .zip\n  - [x] .zipWith\n  - [x] .sort\n  - [x] .head\n  - [x] .tail\n  - [x] .at\n  - [x] .last\n  - [x] .flatMap\n  - [x] .find\n  - [x] .drop\n  - [x] .take\n  - [x] .takeWhile\n  - [x] .groupBy\n  - [x] .join\n  - [x] .map\n  - [x] .filter\n  - [x] .reduce\n  - [x] .reduceRight\n  - [x] .reverse\n  - [x] .every\n  - [x] .splitAt\n  - [x] .toUnion\n  - [x] .toIntersection\n  - [x] .prepend\n  - [x] .append\n  - [x] .concat\n  - [x] .min\n  - [x] .max\n  - [x] .sum\n- [x] objects\n  - [x] accessing properties\n- [x] mapped types\n- [ ] records\n- [x] unions\n- [x] intersections\n- [x] string literals\n- [x] match\n- [x] first-class testing framework? (kinda)\n- [x] syntax highlighting (barely works)\n\n## Syntax highlighting\n\nCurrently one can symlink the `tartak-syntax-highlighter` to the `~/.vscode/extensions` directory to get syntax highlighting in Visual Studio Code.\nTODO: publish the extension to the marketplace.\n\n- later TODO: create a language server.\n\n## internal notes\n\n`this[\"arg0\"]` is the captured environment of the function, parameters are stored in `this[\"arg1\"], this[\"arg2\"], ...`.\nBecause hotscript supports up to 4 arguments, then **tartak functions support up to 3 arguments.**\n\nThis should be fine, because one of the argument can always be a tuple or an object.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmieszkosabo%2Ftartak","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmieszkosabo%2Ftartak","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmieszkosabo%2Ftartak/lists"}