{"id":20425426,"url":"https://github.com/catseye/castile","last_synced_at":"2026-05-26T23:07:56.873Z","repository":{"id":5594555,"uuid":"6801178","full_name":"catseye/Castile","owner":"catseye","description":"MIRROR of https://codeberg.org/catseye/Castile : A simple imperative language with union types (and a compiler for same, with multiple targets)","archived":false,"fork":false,"pushed_at":"2023-10-25T15:23:47.000Z","size":183,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-05T05:15:43.623Z","etag":null,"topics":["compiler","experimental-language","flow-typing","interpreter","multiple-backends","multiple-targets","parse-dont-validate","programming-language","typecase","union-type","union-types"],"latest_commit_sha":null,"homepage":"https://catseye.tc/node/Castile","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/catseye.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.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":"2012-11-21T18:54:38.000Z","updated_at":"2024-01-13T23:51:05.000Z","dependencies_parsed_at":"2025-01-15T15:09:07.622Z","dependency_job_id":"389b7e3f-2f3a-4348-9d1e-e11a534e8655","html_url":"https://github.com/catseye/Castile","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/catseye/Castile","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catseye%2FCastile","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catseye%2FCastile/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catseye%2FCastile/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catseye%2FCastile/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/catseye","download_url":"https://codeload.github.com/catseye/Castile/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catseye%2FCastile/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33542438,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"ssl_error","status_checked_at":"2026-05-26T15:22:15.568Z","response_time":63,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["compiler","experimental-language","flow-typing","interpreter","multiple-backends","multiple-targets","parse-dont-validate","programming-language","typecase","union-type","union-types"],"created_at":"2024-11-15T07:13:16.170Z","updated_at":"2026-05-26T23:07:56.856Z","avatar_url":"https://github.com/catseye.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Castile\n=======\n\nVersion 0.5 | _Entry_ [@ catseye.tc](https://catseye.tc/node/Castile)\n| _See also:_ [Eightebed](https://codeberg.org/catseye/Eightebed#the-eightebed-programming-language)\n∘ [Dieter](https://codeberg.org/catseye/Dieter#the-dieter-programming-language)\n\n- - - -\n\nThis is the reference distribution for **Castile**, a simple imperative\nlanguage with union types.\n\nThe design of Castile was influenced (in varying degrees) by C, Rust,\nEightebed, Python, Ruby, and Erlang.  More information on its roots can\nbe found in [doc/Design.md](doc/Design.md).\n\nThe reference implementation can both interpret Castile programs and\ncompile them to a variety of targets — JavaScript, Ruby, C, and a generic\nstack-based VM (included in this distribution).\n\nA rich test suite in [Falderal][] format, which describes the language\nwith many examples, can be found in [tests/Castile.md](tests/Castile.md).\n\nQuick Start\n-----------\n\nClone this repository, `cd` into the repo directory and run\n\n    bin/castile eg/hello.castile\n\nAlternately, put the `bin` subdirectory on your executable search path, so\nthat you can run `castile` from any directory on your system.  `castile`\nhas no dependencies besides Python (either Python 2 or Python 3.)\n\nMotivating Example\n------------------\n\nHere are some functions for creating linked lists, written in Castile:\n\n    struct list {\n      value: integer;\n      next: list|void;\n    }\n\n    fun empty() {\n      return null as list|void\n    }\n\n    fun cons(v: integer, l: list|void) {\n      make list(value:v, next:l) as list|void\n    }\n\nIn this, `list|void` is a union type.  In this case it is expressing\nthe fact that the value can be either a `list` or `void` — the moral\nequivalent of \"nullable\".  In order to access any of the concrete types\nof a union type, one must use `typecase`:\n\n    fun max(l: list|void) {\n      u = l;\n      v = u;\n      n = 0;\n      while true {\n        typecase u is void {\n          break;\n        }\n        typecase u is list {\n          if u.value \u003e n {\n            n = u.value\n          }\n          v = u.next;\n        }\n        u = v;\n      }\n      return n\n    }\n\nThis retains type-safety; the code will never unexpectedly be presented\nwith a null value.\n\nUnion types can also encourage the programmer follow a [Parse, don't validate][]\napproach (which, despite the impression you might get from reading that article,\nis not restricted to Haskell or even to functional programming).  In the above\ncode, `cons` will never return a `void`, and `max` is not defined on empty lists.\nSo ideally, we'd like to tighten their types to exclude those.  And we can:\n\n    ...\n\n    fun cons(v: integer, l: list) {\n      make list(value:v, next:l as list|void)\n    }\n\n    fun singleton(v: integer) {\n      make list(value:v, next:null as list|void)\n    }\n\n    fun max(l: list) {\n      u = l as list|void;\n      v = u;\n      ...\n    }\n\nMany more examples of Castile programs can be found in\n[tests/Castile.md](tests/Castile.md).\n\n[Falderal]: https://catseye.tc/node/Falderal\n[Parse, don't validate]: https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcatseye%2Fcastile","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcatseye%2Fcastile","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcatseye%2Fcastile/lists"}