{"id":13871863,"url":"https://github.com/kara-lang/Kara","last_synced_at":"2025-07-16T01:31:51.350Z","repository":{"id":43692925,"uuid":"394953791","full_name":"kara-lang/Kara","owner":"kara-lang","description":"An experimental functional programming language with dependent types, inspired by Swift and Idris.","archived":false,"fork":false,"pushed_at":"2022-08-09T13:29:04.000Z","size":639,"stargazers_count":44,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-08-06T23:51:04.811Z","etag":null,"topics":["dependent-types","functional-programming","programming-language","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kara-lang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-08-11T10:42:22.000Z","updated_at":"2024-03-18T19:51:41.000Z","dependencies_parsed_at":"2022-09-17T00:11:29.991Z","dependency_job_id":null,"html_url":"https://github.com/kara-lang/Kara","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kara-lang%2FKara","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kara-lang%2FKara/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kara-lang%2FKara/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kara-lang%2FKara/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kara-lang","download_url":"https://codeload.github.com/kara-lang/Kara/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226089951,"owners_count":17572112,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["dependent-types","functional-programming","programming-language","swift"],"created_at":"2024-08-05T23:00:28.503Z","updated_at":"2024-11-23T19:31:19.214Z","avatar_url":"https://github.com/kara-lang.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"# Kara\n\nAn experimental functional programming language with dependent types, inspired by [Swift](https://swift.org) and [Idris](https://www.idris-lang.org).\n\n## Motivation\n\nDevelopment of Kara is motivated by:\n\n1. **Strong type safety**. Kara relies on dependent types to eliminate bugs at compile time that can't be caught by mainstream languages.\n2. **Familiar syntax**. Kara's syntax should be familiar to everyone experienced with C language family, including Rust, Swift, TypeScript etc.\n3. **Portability**. Kara is developed with support for all major platforms in mind. We want Kara apps to be usable in the browser, as a system programming language, and potentially even in embedded settings, like Arduino, kernel extensions, audio DSP plugins etc.\n4. **Performance**. Where it's possible to compile Kara to native binary code, we want it to be as performant as Swift, but ideally it should as fast as Rust, Zig, or C/C++.\n5. **Language Minimalism**. Kara shouldn't ever become a huge language. Whatever can be implemented as a library should be implemented as a library instead of adding a new feature to the language, as long as it doesn't conflict with the rest of the goals.\n6. **Distribution Minimalism and Economic Accessibility**. A barebone distribution of Kara ready for basic development shouldn't take more than a hundred megabytes when installed as a native binary. Our users shouldn't need a ton of free storage, expensive hardware, and fiber broadband to get started. Additionally, Kara's toolchain should be available and working directly in a browser playground without a need to compile on cloud servers.\n\n## What's a dependent type?\n\nWith dependent types one could prevent out-of-bounds errors at compile time. For example, this code in Kara tries to access array elements\nthat don't exist, but it won't type check:\n\n```swift\nlet a1 = [1,2,3]\na1[3] // type error, out of bounds\nlet a2 = [4,5,6]\n(a1 ++ a2)[6] // type error, OOB\n```\n\nThis is achieved by encoding length of a collection in its type. Here `[1, 2, 3]` has type `Vector\u003cInt, 3\u003e`, which requires \nits subscript arguments to be less than vector's length. These constraints are checked at compile time, but work even for \nvector length computed at run time. Vector length is propagated to new vectors created at run time thanks to the generic vector\nconcatenation operator `++`. Its type signature looks like this:\n\n```swift\n(++): \u003cElement, Length1, Length2\u003e(\n  Vector\u003cElement, Length1\u003e, \n  Vector\u003cElement, Length2\u003e\n) -\u003e Vector\u003cElement, Length1 + Length2\u003e\n```\n\nHere `Element`, `Length1`, and `Length2` are implicit generic arguments that refer to vector's element type and lengths of vectors.\n\nThe concept of dependent types allows us to use expressions in generic arguments of other types, like in `Vector\u003cElement, Length1 + Length2\u003e`\nabove. Here type of a vector depends on a value of its length. This allows us to check not only OOB for simple one-dimensional collections,\nbut also matrix/tensor operations, pointers etc.\n\nOne other interesting application of dependent types are implementations of state machines where [illegal state transitions don't type\ncheck](https://stackoverflow.com/questions/33851598/using-idris-to-model-state-machine-of-open-close-door). \nWhile this is something that's possible in Swift with phantom types, we want it to feel much more natural in Kara with its type system.\n\n## Current status\n\nExample code from the previous section will not currently compile, or even type-check, although fixing this is the primary goal right now. \nKara is at a very early stage and is not available for general or limited use at this moment. The project currently contains only a\nbasic parser, type checker, interpreter, and JavaScript codegen. Documentation is sparse and most of the features are still in flux. Pre-release\nversions are currently only tagged for a purpose of some future retrospective.\n\nStar and watch the repository if you're interested in imminent updates.\n\n## Contributing\n\nIf you'd like to contribute, please make sure you have a general understanding of Idris and ideally have read at least foundational parts\nof [Type-Driven Development with Idris](https://www.manning.com/books/type-driven-development-with-idris) book, which inspire\ndevelopment of Kara. This is not a hard requirement for working on the Kara compiler, but it would be very helpful for all contributors to\nbe on the same page with the general approach to designing the language.\n\n### Code of Conduct\n\nThis project adheres to the [Contributor Covenant Code of\nConduct](https://github.com/kara-lang/Kara/blob/main/CODE_OF_CONDUCT.md).\nBy participating, you are expected to uphold this code. Please report\nunacceptable behavior to conduct@kara-lang.org.\n\n## License\n\nKara is available under the Apache 2.0 license.\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the [LICENSE](https://github.com/kara-lang/Kara/blob/main/LICENSE) file for\nmore info.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkara-lang%2FKara","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkara-lang%2FKara","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkara-lang%2FKara/lists"}