{"id":22022842,"url":"https://github.com/frankbro/ordo","last_synced_at":"2025-09-24T15:32:15.228Z","repository":{"id":144253261,"uuid":"144430615","full_name":"FrankBro/ordo","owner":"FrankBro","description":"Ordo: A minimalist language with row polymorphism","archived":false,"fork":false,"pushed_at":"2024-07-14T19:26:06.000Z","size":3294,"stargazers_count":82,"open_issues_count":3,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-08T13:18:51.485Z","etag":null,"topics":["compiler","programming-language","records","row-polymorphism","variants"],"latest_commit_sha":null,"homepage":"https://frankbro.github.io/ordo/","language":"Rust","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/FrankBro.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":"2018-08-12T01:58:39.000Z","updated_at":"2025-01-05T14:50:57.000Z","dependencies_parsed_at":"2023-12-03T04:22:46.867Z","dependency_job_id":"790cfcf8-f6e0-4ccb-adc8-c0f61205e945","html_url":"https://github.com/FrankBro/ordo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrankBro%2Fordo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrankBro%2Fordo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrankBro%2Fordo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrankBro%2Fordo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FrankBro","download_url":"https://codeload.github.com/FrankBro/ordo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234097000,"owners_count":18779387,"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":["compiler","programming-language","records","row-polymorphism","variants"],"created_at":"2024-11-30T06:25:27.204Z","updated_at":"2025-09-24T15:32:14.738Z","avatar_url":"https://github.com/FrankBro.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"![example workflow](https://github.com/frankbro/ordo/actions/workflows/rust.yml/badge.svg)\n\n# Ordo\n\nLatin : ordo\n\nEnglish : a methodical series, arrangement, or order; regular line, row, or series\n\n## Introduction\n\nA minimal statically-typed programming language focused around row polymorphism, which allows to infer structural types: records and variants.\n\n* Polymorphic types:\n```ocaml\nordo\u003e\u003e\u003e let f(x) = x\nforall a =\u003e a -\u003e a\nfun(x)\n```\n\n* Records:\n```ocaml\nordo\u003e\u003e\u003e let record = { x = 1, y = 2 }\n{x: int, y: int}\n{x: 1, y: 2}\n```\n\n* Variants:\n```ocaml\nordo\u003e\u003e\u003e let variant = :variant 1\nforall ra. (ra\\variant) =\u003e [variant: int | ra]\n:variant 1\n```\n\nThe extra syntax at the end of the variant means it is an open variant. Rows (record or variants) can be open or closed. By default, record literals are closed but variant literals are open. Rows also infer their restrictions. \n\nHere, `forall` signifies that generic types will be given next. We might also have a portion between parenthesis, indicating row restrictions. In this case, for a generic type `ra`, which we know is a row because it's followed by the restriction that this row should not have the value `variant`. Next we finally have the actual type of our expression, we know it's a variant because it's surrounded by `\u003c \u003e`, whereas records are surrounded by `{ }`. The type of the expression is a variant that extends the generic row `r` by having a new case that is specified: `variant` of type `int`.\n\n## Record\n\n* Record initialization\n```ocaml\nordo\u003e\u003e\u003e {}\n{}\n{}\n```\n* Record extension adds fields to the record\n```ocaml\nordo\u003e\u003e\u003e { x = 1 | {} }\n{x: int}\n{x: 1}\n```\n* Record initialization, being sugar for record extension\n```ocaml\nordo\u003e\u003e\u003e { x = 1 } == { x = 1 | {} }\nbool\ntrue\n```\n* The order of insertion of labels is not important\n```ocaml\nordo\u003e\u003e\u003e { x = 1, y = 2 } == { y = 2, x = 1 }\nbool\ntrue\n```\n* Record restriction removes fields from a record\n```ocaml\nordo\u003e\u003e\u003e { x = 1 }\\x == {}\nbool\ntrue\n```\n* Record cannot have the same label twice\n```ocaml\nordo\u003e\u003e\u003e { x = 1, x = 2 }\nerror: parser: duplicate label: x\n```\n\nIn fact, we can see this property being infered by the type system and shown:\n\n```ocaml\nordo\u003e\u003e\u003e let f(r) = { y = 0 | r }\nforall ra. (ra\\y) =\u003e {ra} -\u003e {y: int | ra}\nfun(r)\nordo\u003e\u003e\u003e f({ x = 0 })\n{x: int, y: int}\n{x: 0, y: 0}\n```\n\nThe signature here specifies that the function takes a row that does not contain the field `y`. If you provide a record with the field `y` already it in, the type inference won't let you.\n\n```ocaml\nordo\u003e\u003e\u003e f({ y = 1 })\nerror: infer: row constraint failed for label: y\n```\n\n* Structual pattern matching and even make sure it is valid via type checking:\n\n```ocaml\nordo\u003e\u003e\u003e let { x = x } = { x = 1 }\n{x: int}\n{x: 1}\nordo\u003e\u003e\u003e x\nint\n1\nordo\u003e\u003e\u003e let { y = y } = { x = 1 }\nerror: infer: missing label: y\n```\n\n* Record matching is open\n\nWhile record literals are closed rows, record matching is open:\n\n```ocaml\nordo\u003e\u003e\u003e let record = { x = 0 }\n{x: int}\n{x: 0}\nordo\u003e\u003e\u003e let f({ x = x }) = x\nforall a ra. (ra\\x) =\u003e {x: a | ra} -\u003e a\nfun({x: x})\n```\n\n* Sugar for matching and creation\n\nRecords can either directly assign fields to variables in a shorthand syntax or capture variables via closure and set them automatically to their variable name as label:\n\n```ocaml\nordo\u003e\u003e\u003e let f({x,y}) = x + y\nforall ra. (ra\\x\\y) =\u003e {x: int, y: int | ra} -\u003e int\nfun({x: x, y: y})\nordo\u003e\u003e\u003e let x = 1\nint\n1\nordo\u003e\u003e\u003e let y = 2\nint\n2\nordo\u003e\u003e\u003e f({x,y})\nint\n3\n```\n\n## Variant\n\nThe few new expressions introduced for variants:\n\n* Variant creation\n\n```ocaml\nordo\u003e\u003e\u003e let variant = :variant 1\nforall ra. (ra\\variant) =\u003e [variant: int | ra]\n:variant 1\n```\n\n* Variant elimination\n\nVariant can be eliminated via pattern matching. While variant literals are open rows, we can deduce if the input if open on closed based on the fact that a default case is provided or not.\n\n```ocaml\nordo\u003e\u003e\u003e let default_with(default, value) = match value { :some value -\u003e value, :none x -\u003e default }\nforall a b =\u003e (a, [none: b, some: a]) -\u003e a\nfun(default, value)\n```\n\nIn this case, we did not provide a default case and therefore, the variant was infered to be closed. However, if we wrote it this way:\n\n```ocaml\nordo\u003e\u003e\u003e let is_success(v) = match v { :success a -\u003e true , otherwise -\u003e false }\nforall a ra. (ra\\success) =\u003e [success: a | ra] -\u003e bool\nfun(v)\n```\n\nThis is useful to make sure which variant can be passed in.\n\n```ocaml\nordo\u003e\u003e\u003e is_success(:fail 0)\nbool\nfalse\nordo\u003e\u003e\u003e default_with(1, :fail 0)\nerror: infer: missing label: fail\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrankbro%2Fordo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrankbro%2Fordo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrankbro%2Fordo/lists"}