{"id":22531370,"url":"https://github.com/owaismohsin001/czariscript","last_synced_at":"2025-03-28T05:18:53.645Z","repository":{"id":193433088,"uuid":"455233784","full_name":"owaismohsin001/CzariScript","owner":"owaismohsin001","description":"A functional/OO programming language with global subtype inference","archived":false,"fork":false,"pushed_at":"2022-04-07T15:08:58.000Z","size":373,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-02T06:13:26.822Z","etag":null,"topics":["inheritance","prototypes","structural-types","subtype","subtype-inference","type-inference"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/owaismohsin001.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2022-02-03T16:08:28.000Z","updated_at":"2022-03-31T17:54:24.000Z","dependencies_parsed_at":"2023-09-08T06:52:02.346Z","dependency_job_id":null,"html_url":"https://github.com/owaismohsin001/CzariScript","commit_stats":null,"previous_names":["ameerwasi001/czariscript","zaidharoon001/czariscript","owaismohsin001/czariscript"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owaismohsin001%2FCzariScript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owaismohsin001%2FCzariScript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owaismohsin001%2FCzariScript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owaismohsin001%2FCzariScript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/owaismohsin001","download_url":"https://codeload.github.com/owaismohsin001/CzariScript/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245972986,"owners_count":20702757,"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":["inheritance","prototypes","structural-types","subtype","subtype-inference","type-inference"],"created_at":"2024-12-07T08:07:14.214Z","updated_at":"2025-03-28T05:18:53.626Z","avatar_url":"https://github.com/owaismohsin001.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CzariScript\nThe CzariScript has a type system that supports subtype inference with parametric polymorphism, classes, objects, and single inheritance. It compiles to JavaScript and the output runs in the browser, and deno.\n\n## Structure of CzariScript\nA CzariScript program contains a sequence of definitions, and expressions separated by semicolons. The definitions are all evaluated before expressions. Here's an example of a CzariScript program.\n```\nx = 1;\ny = \"abc\";\nprintln x;\n```\n\n## Literals\nCzariScript has all the literal you would expect from a language of its kind. Here are the literals this language supports `1`, `\"ABC\"`, `true`, `false`, tuples, and records.\n\n## If statements\n```\nif x then \"a\" else \"b\"\n```\nThis does what you think it does, but the most important part is that you can have different types in the then-expression and else-expression. This would theoretically work like this.\n```\nif x then 1 else \"a\"\n```\n\n## Functions\nFunctions can be defined by using a lambda like such `\\x -\u003e x` but a named function may also be defined like such `f x = x`. All functions in CzariScript take one argument and return one result but functions are automatically curried. Here's an example `f x y = x + y` which just `f = \\x -\u003e \\y -\u003e x + y`.\n\n## Applications\nFunctions can be applied like such `f 1 2` which of course only works for curried functions. In this particular example, this code would return `3` where `f x y = x + y`\n\n## Records\nRecords and Tuples are one and same in CzariScript, and you may use the following syntax for them. `{a: 3, b: 4}` which defines a record with fields `a`, and `b` having values `3`, and `4` respectively, while `{1, 3}` defines a record with fields `0`, and `1` with values `1`, and `3`, which is a tuple as far as the compiler is concerned. For syntactical convenience, it may be written as `(1, 3)`.\n\n## Record inheritance\nA record can inherit from another record, here's an example.\n```\nobj = {a: 3}\nobjExtended = {b: 2 with obj}\n```\n\n## Classes\nFollowing is how you define classes\n```\nobjC = class n so\n    x = n;\nend;\n```\n\nHere the class takes one argument named `n` and returns a record with fields `{x: n}`. You define a method like this\n```\ngetX self n = self.x + n\n```\nwhich can be called like such `obj:getX 2`. Classes may also define static methods as such\n```\nstatic fromNothing _ = objC.new 0\n```\n\n## Class Inheritance\nClasses can inherit from other classes both on the object and the class level. Here's how inheritance works\n```\nclass n with textC::textC.new \"Hello\"...\n```\nHere the `textC` before `::` shows what to inherit from, on the class level, and the expression after the `::` shows what to inherit at the object level, in this case, it is the same thing.\n\n## Let \u0026 Where\n`let` and `where` both define some value that goes through the process of Let-generalisation but the difference between them is that the latter allows recursive definition while the former does not. The syntax for `let` is \n```\nlet f x = x*2 in f 10\n```\nwhile the syntax of `where` is \n```\nfac 10 where fac n = if n = 1 then 1 else n*fac(n-1)\n```\n\n## A series of actions\nCzariScript like OCaml is anything but a pure language so you do need to perform multiple actions in a definition and here's how you'd do that.\n```\nlet something = do\n    println \"Hello!\";\n    let name = \"Name\"\n    println (\"How are you \" \u0026 name \u0026 \"?\")\nend\n```\n\nOne of the primary use-cases of this is when you deal with a mutable reference.\n\n## References\nA reference in CzariScript is something that can be mutated from any function in the codebase. You can create with syntax inspired by Pascal style reference with `@expression`, dereference with `expression^`, and assignment with `expression ^= another_expression`.\n\n## Module System\nHere's the simple module system of CzariScript. You can import files with `import FileName` where the name should be specified with a capital letter in the beginning. These modules may export their definitions with the syntax of `export {x: something, y: anotherThing}` or `export {something, anotherThing}`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fowaismohsin001%2Fczariscript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fowaismohsin001%2Fczariscript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fowaismohsin001%2Fczariscript/lists"}