All Projects → joshsharp → Braid

joshsharp / Braid

Licence: mit
A functional language with Reason-like syntax that compiles to Go.

Programming Languages

go
31211 projects - #10 most used programming language
ocaml
1615 projects
language
365 projects

Labels

Projects that are alternatives of or similar to Braid

Reason Loadable
🔥 Suspense/Lazy for ReasonReact.
Stars: ✭ 88 (-27.27%)
Mutual labels:  reasonml
Dmmf
Implementing Scott Wlaschin's “Domain Modeling Made Functional” in Rust, Elm, F♯, and ReasonML
Stars: ✭ 103 (-14.88%)
Mutual labels:  reasonml
Wonder Editor
Functional 3D Webgl Editor
Stars: ✭ 113 (-6.61%)
Mutual labels:  reasonml
Ppx bs css
A ppx rewriter for CSS expressions.
Stars: ✭ 98 (-19.01%)
Mutual labels:  reasonml
Routes
typed bidirectional routes for OCaml/ReasonML web applications
Stars: ✭ 102 (-15.7%)
Mutual labels:  reasonml
99.re
99 problems with reason(able) solutions.
Stars: ✭ 106 (-12.4%)
Mutual labels:  reasonml
Timerlab
⏰ A simple and customizable timer
Stars: ✭ 84 (-30.58%)
Mutual labels:  reasonml
Re Tailwind
Brings TailwindCSS https://tailwindcss.com to ReasonML
Stars: ✭ 118 (-2.48%)
Mutual labels:  reasonml
Reason Reactify
🚀 Transform a mutable tree into a functional React-like API
Stars: ✭ 102 (-15.7%)
Mutual labels:  reasonml
Awesome Reasonml
A collection of awesome things regarding Reason/OCaml ecosystem.
Stars: ✭ 1,473 (+1117.36%)
Mutual labels:  reasonml
Reason React Native Web Example
Razzle + Reason-React + React-Native-Web. Damn that's a lot of R's.
Stars: ✭ 98 (-19.01%)
Mutual labels:  reasonml
Jsoo React
js_of_ocaml bindings for ReactJS. Based on ReasonReact.
Stars: ✭ 101 (-16.53%)
Mutual labels:  reasonml
Reason Mode
Emacs major mode for working with ReasonML
Stars: ✭ 108 (-10.74%)
Mutual labels:  reasonml
A Reason React Tutorial
included code for A ReasonReact Tutorial
Stars: ✭ 94 (-22.31%)
Mutual labels:  reasonml
Rescript Recoil
Zero-cost bindings to Facebook's Recoil library
Stars: ✭ 115 (-4.96%)
Mutual labels:  reasonml
Lenses Ppx
PPX to derive GADT lenses for ReasonML
Stars: ✭ 85 (-29.75%)
Mutual labels:  reasonml
Verified React
Automated reasoning for React/ReasonML
Stars: ✭ 104 (-14.05%)
Mutual labels:  reasonml
Reroute
a fast, declarative microrouter for reason-react
Stars: ✭ 120 (-0.83%)
Mutual labels:  reasonml
Ocamlverse.github.io
Documentation of everything relevant in the OCaml world
Stars: ✭ 117 (-3.31%)
Mutual labels:  reasonml
Reason Calculator
A calculator built with Reason and reason-react.
Stars: ✭ 110 (-9.09%)
Mutual labels:  reasonml

Braid

A functional language with Reason-like syntax that compiles to Go.

I’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, 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.

I've written some more about it on my Braid dev blog.

Status

Very, very alpha.

Goals

  • Pair an OCaml-like language with the benefits of the Go platform (speed, concurrency, static binaries, a healthy ecosystem)
  • Bring powerful FP concepts to Go
  • Get around Go's lack of generics
  • Interop with Go code
  • Ability to use Go stdlib

Non-goals

  • Performance matching idiomatic Go
  • Just reimplementing Reason on top of Go

Language overview

Consider anything ticked off to exist in the language, but be barely usable.

  • [X] Record types
  • [X] Variant types
  • [X] If-expressions
  • [X] Importing Go functions and types
  • [X] Immutability by default
  • [X] Hindley-Milner type inference
  • [X] Type annotations
  • [X] Implicit return
  • [X] Multiple return
  • [ ] Modules
  • [ ] Pattern matching
  • [ ] Currying
  • [ ] Typeclasses/traits
  • [ ] Concurrency
  • [ ] Infix operators

Braid supports records and variants:

type Person = {
  name: string,
  age: int64,
}

type Fruit = 
  | Peach
  | Plum
  | Pear

type Option ('a) =
  | Some ('a)
  | None
  
let result = Some("it worked")

Braid attempts to support significant newlines, meaning no ; required — however this is probably broken in a lot of cases right now.

A full example:

module Main

// record type
type Payload = {
  name: string,
  data: string,
}

// go interop - external functions must be annotated
extern func println = "fmt.Println" (s: string) -> ()
extern func printf1 = "fmt.Printf" (s: string, arg1:string) -> ()

/* func to add cheesiness to any two items */
let cheesy = (item, item2) {
  item ++ " and " ++ item2 ++ " with cheese please"
}

let main = {
  // nested functions
  let something = {
    4 + 9
  }
  let a = something()
  let yumPizza = cheesy("pineapple", "bbq sauce")
  println(yumPizza)
  // calling a go function
  printf1("Woo I can print %s\n", "6")
  let b = Payload{name: "greeting", data: "hi"}
  println(b.name)
}

Trying it out

Grab the correct Braid package for your platform from the releases, extract the braid binary, and run it.

./braid filename.bd

This will compile your Braid file to Go and print the resulting Go source code to stdout.

./braid filename.bd > main.go

You can redirect this into a file if you like.

Developing

Requirements

Building

Making sure Go and GB are in your path, clone the Braid repository into a new directory:

git clone https://github.com/joshsharp/braid.git

Enter the new braid directory and fetch the requirements:

cd braid
gb vendor restore

Make sure the vendored dependencies are built (you'll only need to do this once):

cd vendor
gb build all

Use the makefile at src/braid/Makefile to build and run Braid:

cd ../src/braid
make run file=examples/example.bd

FAQ

Will Braid support X?

I don't know yet. I'm open to proposals, provided you help me do the work.

Do you even know what you're doing?

Nope, 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.

Contributing

Contribution guidelines

Your help makes Braid better! I welcome pull requests, bug fixes, and issue reports.

Before proposing a change, please first create an issue to discuss your proposal.

License

Licensed under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].