{"id":13787724,"url":"https://github.com/joshsharp/braid","last_synced_at":"2025-05-12T01:31:37.683Z","repository":{"id":73238896,"uuid":"134855932","full_name":"joshsharp/braid","owner":"joshsharp","description":"A functional language with Reason-like syntax that compiles to Go.","archived":true,"fork":false,"pushed_at":"2019-04-24T05:59:31.000Z","size":833,"stargazers_count":139,"open_issues_count":0,"forks_count":3,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-11-14T20:55:11.735Z","etag":null,"topics":["functional-languages","go","language","ocaml","reasonml"],"latest_commit_sha":null,"homepage":null,"language":"Go","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/joshsharp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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-05-25T12:54:12.000Z","updated_at":"2024-10-31T21:44:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"b62226a2-16fd-40d9-a70f-e91125ef9c6f","html_url":"https://github.com/joshsharp/braid","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshsharp%2Fbraid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshsharp%2Fbraid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshsharp%2Fbraid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshsharp%2Fbraid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joshsharp","download_url":"https://codeload.github.com/joshsharp/braid/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253659379,"owners_count":21943627,"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":["functional-languages","go","language","ocaml","reasonml"],"created_at":"2024-08-03T21:00:28.800Z","updated_at":"2025-05-12T01:31:37.146Z","avatar_url":"https://github.com/joshsharp.png","language":"Go","readme":"# Braid\nA functional language with Reason-like syntax that compiles to Go.\n\nI’m working on a language I’m calling Braid, an ML-like language that compiles to Go. Braid’s syntax is heavily inspired by [Reason](https://reasonml.github.io/), itself a more C-like syntax on top of OCaml. So really I’m writing a language that aims to be fairly similar to OCaml in what it can do, but visually a bit closer to Go. I’m not trying to reimplement OCaml or Reason 1:1 on top of Go, but build something sharing many of the same concepts.\n\nI've written some more about it on my [Braid dev blog](https://braid.joshsharp.com.au/).\n\n## Status\n\nVery, very alpha.\n\n## Goals\n- Pair an OCaml-like language with the benefits of the Go platform (speed, concurrency, static binaries, a healthy ecosystem)\n- Bring powerful FP concepts to Go\n- Get around Go's lack of generics\n- Interop with Go code\n- Ability to use Go stdlib\n\n## Non-goals\n- Performance matching idiomatic Go\n- Just reimplementing Reason on top of Go\n\n## Language overview\n\nConsider anything ticked off to exist in the language, but be barely usable.\n\n- [X] Record types\n- [X] Variant types\n- [X] If-expressions\n- [X] Importing Go functions and types\n- [X] Immutability by default\n- [X] Hindley-Milner type inference\n- [X] Type annotations\n- [X] Implicit return\n- [X] Multiple return\n- [ ] Modules\n- [ ] Pattern matching\n- [ ] Currying\n- [ ] Typeclasses/traits\n- [ ] Concurrency\n- [ ] Infix operators\n\nBraid supports records and variants:\n\n```\ntype Person = {\n  name: string,\n  age: int64,\n}\n\ntype Fruit = \n  | Peach\n  | Plum\n  | Pear\n\ntype Option ('a) =\n  | Some ('a)\n  | None\n  \nlet result = Some(\"it worked\")\n```\n\nBraid attempts to support significant newlines, meaning no `;` required \u0026mdash; however this is probably broken in a lot of cases right now.\n\nA full example:\n\n```\nmodule Main\n\n// record type\ntype Payload = {\n  name: string,\n  data: string,\n}\n\n// go interop - external functions must be annotated\nextern func println = \"fmt.Println\" (s: string) -\u003e ()\nextern func printf1 = \"fmt.Printf\" (s: string, arg1:string) -\u003e ()\n\n/* func to add cheesiness to any two items */\nlet cheesy = (item, item2) {\n  item ++ \" and \" ++ item2 ++ \" with cheese please\"\n}\n\nlet main = {\n  // nested functions\n  let something = {\n    4 + 9\n  }\n  let a = something()\n  let yumPizza = cheesy(\"pineapple\", \"bbq sauce\")\n  println(yumPizza)\n  // calling a go function\n  printf1(\"Woo I can print %s\\n\", \"6\")\n  let b = Payload{name: \"greeting\", data: \"hi\"}\n  println(b.name)\n}\n```\n\n## Trying it out\n\nGrab the correct Braid package for your platform from the [releases](https://github.com/joshsharp/braid/releases), extract the `braid` binary, and run it.\n\n```sh\n./braid filename.bd\n```\n\nThis will compile your Braid file to Go and print the resulting Go source code to stdout.\n\n```sh\n./braid filename.bd \u003e main.go\n```\n\nYou can redirect this into a file if you like.\n\n## Developing\n\n### Requirements\n- [Go 1.10](https://golang.org/dl/)\n- [GB](https://getgb.io/)\n- [goimports](https://godoc.org/golang.org/x/tools/cmd/goimports)\n\n### Building\n\nMaking sure Go and GB are in your path, clone the Braid repository into a new directory:\n\n```sh\ngit clone https://github.com/joshsharp/braid.git\n```\n\nEnter the new `braid` directory and fetch the requirements:\n\n```sh\ncd braid\ngb vendor restore\n```\n\nMake sure the vendored dependencies are built (you'll only need to do this once):\n\n```sh\ncd vendor\ngb build all\n```\n\nUse the makefile at `src/braid/Makefile` to build and run Braid:\n\n```sh\ncd ../src/braid\nmake run file=examples/example.bd\n```\n\n## FAQ\n### Will Braid support X?\n\nI don't know yet. I'm open to proposals, provided you help me do the work.\n\n### Do you even know what you're doing?\n\nNope, not at all. I have no formal background in this stuff. Really I'm doing it for fun. I'd love to see it reach maturity, because I want to use it myself. But I'll need a lot of help if it's to get that far.\n\n## Contributing\n### Contribution guidelines\nYour help makes Braid better! I welcome pull requests, bug fixes, and issue reports.\n\nBefore proposing a change, please first create an issue to discuss your proposal.\n\n## License\n\nLicensed under the [MIT License](https://choosealicense.com/licenses/mit/).\n","funding_links":[],"categories":["Functional"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshsharp%2Fbraid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoshsharp%2Fbraid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshsharp%2Fbraid/lists"}