{"id":9765094,"url":"https://github.com/HigherOrderCO/Kind1","last_synced_at":"2025-08-27T09:32:03.598Z","repository":{"id":37328616,"uuid":"140790634","full_name":"HigherOrderCO/Kind1","owner":"HigherOrderCO","description":"A next-gen functional language","archived":false,"fork":false,"pushed_at":"2024-05-17T02:22:49.000Z","size":36084,"stargazers_count":3493,"open_issues_count":54,"forks_count":136,"subscribers_count":75,"default_branch":"master","last_synced_at":"2024-05-19T11:10:56.056Z","etag":null,"topics":["dependent-types","formality","functional-programming","lambda-calculus","moonad","proof-language","proof-languages","theorem-prover","type-theory"],"latest_commit_sha":null,"homepage":"https://higherorderco.com","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HigherOrderCO.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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":"2018-07-13T03:08:55.000Z","updated_at":"2024-06-21T02:15:50.254Z","dependencies_parsed_at":"2023-07-14T09:02:51.987Z","dependency_job_id":"6c0426bf-96fc-4df7-a962-0e0c41e8e944","html_url":"https://github.com/HigherOrderCO/Kind1","commit_stats":{"total_commits":470,"total_committers":17,"mean_commits":"27.647058823529413","dds":0.5276595744680851,"last_synced_commit":"2b277492007a843c5285ff9c3b916dd670b972e3"},"previous_names":["kindelia/kind","moonad/formality","kindelia/kind2","higherorderco/kind1"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HigherOrderCO%2FKind1","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HigherOrderCO%2FKind1/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HigherOrderCO%2FKind1/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HigherOrderCO%2FKind1/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HigherOrderCO","download_url":"https://codeload.github.com/HigherOrderCO/Kind1/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":215840624,"owners_count":15938151,"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","formality","functional-programming","lambda-calculus","moonad","proof-language","proof-languages","theorem-prover","type-theory"],"created_at":"2024-05-16T22:13:57.269Z","updated_at":"2024-08-31T19:30:51.101Z","avatar_url":"https://github.com/HigherOrderCO.png","language":"Rust","readme":"# Kind\n\nA minimal, efficient and practical programming language that aims to rethink functional programming from the scratch, and make it right. Under the hoods, it is basically Haskell, except without historical mistakes, and with a modern, consistent design. On the surface, it aims to be more practical, and to look more like conventional languages. Kind is statically typed, and its types are so powerful that you can prove mathematical theorems on it. Compared to proof assistants, Kind has:\n\n1. The smallest core. Check [FormCore.js](https://github.com/moonad/FormCoreJS/blob/master/FormCore.js) or [Core.kind](https://github.com/Kindelia/Kind/blob/master/base/Kind/Core.kind). Both are `\u003c 1000-LOC` complete implementations!\n\n2. Novel type-level features. Check [this article](https://github.com/Kindelia/Kind/blob/master/blog/1-beyond-inductive-datatypes.md) on super-inductive datatypes.\n\n3. An accessible syntax that makes it less scary. Check [SYNTAX.md](https://github.com/Kindelia/Kind/blob/master/SYNTAX.md).\n\n4. A complete bootstrap: the language is implemented in itself. Check it [here](https://github.com/Kindelia/Kind/tree/master/base/Kind).\n\n5. Efficient real-world compilers. Check [http://old.kindelia.org/](http://old.kindelia.org) for a list of apps. (WIP)\n\nUsage\n-----\n![npm](https://img.shields.io/npm/v/kind-lang)  [![telegram](https://img.shields.io/badge/chat-on%20telegram-blue)](https://t.me/kindelia)\n\n0. Choose a release. We'll use JavaScript here but ChezScheme is also [available](/INSTALL.md).\n\n1. Install Kind using `npm`:\n\n```bash\nnpm i -g kind-lang\n```\n\n2. Save the file below as `Main.kind`:\n\n```javascript\nMain: IO(Unit)\n  IO {\n    IO.print(\"Hello, world!\")\n  }\n```\n\n3. Type-check it:\n\n```bash\nkind Main\n```\n\n4. Run it:\n\n```bash\nkind Main --run\n```\n\n5. Have fun!\n\nThings you can do with Kind:\n----------------------------\n\n### Compile programs and modules to several targets.\n\nKind has an universal compiler that targets several back-ends. Just find what you need on Kind, and compile it with `kind Main --lang`. For example, to generate a QuickSort function in JavaScript, just type `kind List.quicksort --js`. You may never write code in any other language! Available targets: `--js`, `--scm`. Several more will be available eventually.\n\n### Create live applications.\n\nKind has an interconnected back-end that allows you to create rich, interactive applications without ever touching databases, TCP packets or messing with apis. Just add a file to `base/App` and it will be available on [http://old.kindelia.org/](http://old.kindelia.org). You can fork entire applications - not just the front-end, but all of it, back-end, database, and networking - in seconds.\n\n### Prove theorems.\n\nNo, theorems are not scary things mathematicians do. For programmers, they're more like unit tests, except they can involve symbols, allowing you to cover infinitely many test cases. If you like unit tests, you'll love theorems. To learn more, check [THEOREMS.md](THEOREMS.md). You can also compile Kind programs and proofs to a minuscle core language with the `--fmc` flag (example: `kind Nat.add.assoc --fmc`). Try it!\n\n### Deploy Smart-Contracts.\n\n(Soon.)\n\nExamples\n--------\n\n### Some programs\n\n```javascript\n// A 'Hello, world!\"\nMain: IO(Unit)\n  IO {\n    IO.print(\"Hello, world!\")\n  }\n```\n\n```javascript\n// Quicksort (using recursion)\nquicksort(list: List\u003cNat\u003e): List\u003cNat\u003e\n  case list {\n    nil:\n      []\n    cons:\n      fst = list.head\n      min = filter!((x) x \u003c? list.head, list.tail)\n      max = filter!((x) x \u003e=? list.head, list.tail)\n      quicksort(min) ++ [fst] ++ quicksort(max)\n  }\n```\n\n```javascript\n// List iteration (using folds)\nsome_text: String\n  List.foldl!!(\"\",\n    (str, result) \n      str = String.to_upper(str)\n      str = String.reverse(str)\n      result | str,\n    [\"cba\",\"fed\",\"ihg\"])\n```\n\n```javascript\n// List iteration (using fors)\nsome_text: String\n  result = \"\"\n  for str in [\"cba\",\"fed\",\"ihg\"] with result:\n    str = String.to_upper(str)\n    str = String.reverse(str)\n    result | str\n  result\n```\n\n```c\n// Map, Maybe, String and Nat sugars\nsugars: Nat\n  key  = \"toe\"\n  map  = {\"tic\": 1, \"tac\": 2, key: 3} // Map.from_list!([{\"tic\",1}, ...])\n  map  = map{\"tic\"} \u003c- 100            // Map.set!(\"tic\", 100, map)\n  map  = map{\"tac\"} \u003c- 200            // Map.set!(\"tac\", 200, map)\n  map  = map{ key } \u003c- 300            // Map.set!(key, 300, map)\n  val0 = map{\"tic\"} \u003c\u003e 0              // Maybe.default!(Map.get!(\"tic\",map), 0)\n  val1 = map{\"tac\"} \u003c\u003e 0              // Maybe.default!(Map.get!(\"tac\",map), 0)\n  val2 = map{ key } \u003c\u003e 0              // Maybe.default!(Map.get!(key, map), 0)\n  val0 + val1 + val2                  // Nat.add(val0, Nat.add(val1, val2))\n```\n\n```c\n// List monadic block: returns [{1,4},{1,5},{1,6},{2,4},...,{3,6}]\nmy_list: List\u003cPair\u003cNat,Nat\u003e\u003e\n  List {\n    get x = [1, 2, 3]\n    get y = [4, 5, 6]\n    return {x, y}\n  }\n```\n\nCheck many List algorithms on [base/List](https://github.com/Kindelia/Kind/tree/master/base/List)!\n\n### Some types\n\n```javascript\n// A boolean\ntype Bool {\n  true\n  false\n}\n```\n\n```javascript\n// A natural number\ntype Nat {\n  zero\n  succ(pred: Nat)\n}\n```\n\n```javascript\n// A polymorphic list\ntype List \u003cA: Type\u003e {\n  nil\n  cons(head: A, tail: List\u003cA\u003e)\n}\n```\n\n```javascript\n// A polymorphic pair\ntype Pair \u003cA: Type, B: Type\u003e {\n  new(fst: A, snd: B)\n}\n```\n\n```javascript\n// A polymorphic dependent pair\ntype Sigma \u003cA: Type, B: A -\u003e Type\u003e {\n  new(fst: A, snd: B(fst))\n}\n```\n\n```javascript\n// A polymorphic list with a statically known size\ntype Vector \u003cA: Type\u003e ~ (size: Nat) {\n  nil                                              ~ (size = 0) \n  cons(size: Nat, head: Nat, tail: Vector\u003cA,size\u003e) ~ (size = 1 + size)\n}\n```\n\n```javascript\n// A bounded natural number\ntype Fin ~ \u003clim: Nat\u003e {\n  zero\u003cN: Nat\u003e               ~ (lim = Nat.succ(N))\n  succ\u003cN: Nat\u003e(pred: Fin\u003cN\u003e) ~ (lim = Nat.succ(N))\n}\n```\n\n```javascript\n// The type used in equality proofs\ntype Equal \u003cA: Type, a: A\u003e ~ (b: A) {\n  refl ~ (b = a)\n}\n```\n\n```javascript\n// A burrito\ntype Monad \u003cM: Type -\u003e Type\u003e {\n  new(\n    bind: \u003cA: Type, B: Type\u003e M\u003cA\u003e -\u003e (A -\u003e M\u003cB\u003e) -\u003e M\u003cB\u003e\n    pure: \u003cA: Type\u003e A -\u003e M\u003cA\u003e\n  )\n}\n```\n\n```javascript\n// Some game entity\ntype Entity {\n  player(\n    name: String\n    pos: V3\n    health: Nat\n    items: List\u003cItem\u003e\n    sprite: Image\n  )\n  wall(\n    hitbox: Pair\u003cV3, V3\u003e\n    collision: Entity -\u003e Entity\n    sprite: Image\n  )\n}\n```\n\nCheck all core types on [base](https://github.com/Kindelia/Kind/tree/master/base)!\n\n### Some proofs\n\n```javascript\n// Proof that `a == a + 0`\nNat.add.zero(a: Nat): a == Nat.add(a, 0)\n  case a {\n    zero: refl\n    succ: apply(Nat.succ, Nat.add.zero(a.pred))\n  }!\n  ```\n\n```javascript\n// Proof that `1 + (a + b) == a + (1 + b)`\nNat.add.succ(a: Nat, b: Nat): Nat.succ(a + b) == (a + Nat.succ(b))\n  case a {\n    zero: refl\n    succ: apply(Nat.succ, Nat.add.succ(a.pred, b))\n  }!\n  ```\n\n```javascript\n// Proof that addition is commutative\nNat.add.comm(a: Nat, b: Nat): (a + b) == (b + a)\n  case a {\n    zero:\n      Nat.add.zero(b)\n    succ: \n      p0 = Nat.add.succ(b, a.pred)\n      p1 = Nat.add.comm(b, a.pred)\n      p0 :: rewrite X in Nat.succ(X) == _ with p1\n  }!\n```\n\nCheck some Nat proofs on [base/Nat/add](https://github.com/Kindelia/Kind/tree/master/base/Nat/add)!\n\n### A web app\n\n```javascript\n// Render function\nApp.Hello.draw: App.Draw\u003cApp.Hello.State\u003e\n  (state)\n  \u003cdiv style={\"border\": \"1px solid black\"}\u003e\n    \u003cdiv style={\"font-weight\": \"bold\"}\u003e\"Hello, world!\"\u003c/div\u003e\n    \u003cdiv\u003e\"Clicks: \" | Nat.show(state@local)\u003c/div\u003e\n    \u003cdiv\u003e\"Visits: \" | Nat.show(state@global)\u003c/div\u003e\n  \u003c/div\u003e\n\n// Event handler\nApp.Hello.when: App.When\u003cApp.Hello.State\u003e\n  (event, state)\n  case event {\n    init: IO {\n      App.watch!(App.room_zero)\n      App.new_post!(App.room_zero, App.empty_post)\n    }\n    mouse_down: IO {\n      App.set_local!(state@local + 1)\n    }\n  } default App.pass!\n```\n\nSource: [base/App/Hello.kind](https://github.com/Kindelia/Kind/blob/master/base/App/Hello.kind)\n\nLive: [http://old.kindelia.org/App.Hello](http://old.kindelia.org/App.Hello)\n\nIn order to run this or any other app you should follow this steps:\n  - The app should be in `base/App` folder\n  - Install necessary packages in web folder with `npm i --prefix web/`\n  - Install `js-beautify` using `sudo npm i -g js-beautify`\n  - Build the app you want with `node web/build [name of app]` (in this example would be `node web/build Hello`)\n  - Run a local server with `node web/server.js 8080`\n  - Open http://localhost:8080 in your favorite browser and see your app working\n\n\nFuture work\n-----------\n\nThere are so many things we want to do and improve. Would like to contribute? Check [CONTRIBUTE.md](https://github.com/Kindelia/Kind/blob/master/CONTRIBUTE.md). Also reach us on [Telegram](https://t.me/kindelia). We're friendly!\n","funding_links":[],"categories":["JavaScript","Uncategorized"],"sub_categories":["Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHigherOrderCO%2FKind1","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FHigherOrderCO%2FKind1","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHigherOrderCO%2FKind1/lists"}