The official compiler for the Quartz programming language
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples Improve testing facilities May 31, 2017
global-synthesis Add FIXME reminders to CFSM merging function Apr 4, 2018
src Correct error in Typecheck.unify and add a unification test Jul 12, 2017
vm
.gitignore Add type pretty-printing Jun 1, 2017
.merlin
IDEAS.md Start listing out ideas for different parts of the Quartz system Apr 5, 2018
LICENSE Switch to Haskell Feb 27, 2017
Makefile Start OCaml rewrite May 26, 2017
README.md Update README.md Oct 8, 2017
_oasis Finish statment parsing, change NUMBER representation May 29, 2017
configure
opam Add type pretty-printing Jun 1, 2017
setup.ml
typing.pl Start fixing AST/Types May 18, 2017

README.md

Quartz

Quartz is a statically typed, concurrent programming language for the BEAM VM based on the actor model with a sleek, Ruby-based syntax and support for functional and object-oriented programming.

Features

  • Familiar Ruby-like syntax
  • First-class concurrency primitives
  • Actor model message passing à la Erlang
  • Static typing for messages based on multiparty session types
  • Duality checking
  • Structural subtyping
  • First-class functions

Roadmap

  • AST
  • Pretty Printing
  • Core Compiler
  • Lexer
  • Parser
  • FFI
  • Tuples
  • Instance Variables (Mutability)
  • Comparison, arithmetic operators
  • Module Compiler
  • Type.t
  • Type parser
  • Type Inference/Type Checking
  • Pattern Matching
  • Syntax Cleanup

Examples

# Server: forall c < ...!{Start ~> ...?{Ok ~> Eps, Err(String) ~> Eps}}.
#         rec self.
#         [client : c]
#         ?client{Start ~> !client{Ok ~> self, Err(String) ~> self}}
session Server
  on Start from sender
    case File.open("file.txt")
    when Success(f)
      sender!Ok
      File.read_into(f, |x| sender!Value(x) end)
    else
      sender!Err("Could not open file.txt!")
    end
  end
  loop
end

# Client: (target : Server) ->
#         !target{Start ~> ?target{Ok ~> Eps, Err(String) ~> Eps}}
session Client (target : Server)
  target!Start

  on Ok from target
    on Value(status) from target
      print(status)
    end
  or Err(e)
    print("Server-side error when opening file: " ++ e)
  end
  close # Closes by default, but can be provided explicitly. Can also use `loop`.
end

fun main
  let server = spawn Server
  spawn Client(server)
end

The above example compiles into the following Erlang output:

-export([server/1, client/1, main/1]).

server(unit) ->
  receive {start, Sender} ->
    io:format("Starting~n", []),
    case file:open("file.txt") of
    {success, F} ->
       Sender!{ok, self()},
       file:read_into(F)(fun(Value) -> Sender!{{value, Value}, self()} end);
    _ ->
        Sender!{err, self()}
    end
  end.

client(Target) ->
  io:format("Starting~n", []),
  Target!{start, self()},
  
  receive
    {ok, Sender} ->
      receive {{value, Status}, Sender} ->
        print(Status),
        close(unit)
      end;
    {err, Sender} ->
      print("Server-side error when opening file"),
      close(unit)
  end.

main(_) ->
  Server = spawn(ex, server, [unit]),
  spawn(ex, client, [Server]).