New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mega PR with completed node container and working round trip #88

merged 35 commits into from Aug 12, 2016


None yet
1 participant

pchiusano commented Aug 12, 2016

This is a huge and not very organized PR. :) Lots of hacking to get things working and I didn't bother trying to keep commit history pretty. Here is a summary:

First, stack build unison-node && stack exec container builds a new executable, container, which spins up an HTTP server that accepts remote Unison programs for evaluation. Those programs can spawn other nodes, etc. Here's an example Unison program that actually works:

-- Spawn two nodes, and bounce a value back and forth between them, incrementing
-- each time, until 5 bounces have taken place
Remote {
  n1 := Remote.spawn;
  n2 := Remote.spawn;
  let rec
    ping i = Remote { 
      i := n2 (i + 1); 
      if (i >= 5) (pure i) (pong i); 
    pong i = Remote { i := n1 (i + 1); ping i; }
  in ping 0;

See the comment in node/tests/pingpong.u file for info on how to actually run this once your container is running.

As is shown in that file, the parser has been modified to support 'effect blocks'. As we don't have typeclasses in Unison, the effect type must be specified (here, we're specifying Remote, but any effect with pure and bind methods will work). The translation is purely syntactic.

Other stuff implemented in this PR:

  • A number of additional builtins, including if, True, False, >, <, <=,==, >=. The comparison ops are specialized to numbers at the moment in the parser. In the editor, we could easily overload these symbols, even without typeclasses.
  • Added a very simple logging utility, in shared Unison.Util.Logger.
  • Now using configurator package for config. See Unison.Config in node package, which has some utilities for loading a logger using the config file.
  • Typechecker improvement - let bindings which are closed are generalized, for instance the following now typechecks: let id x = x; y = id 42; z = id "woot" in z
  • Unison.Typechecker.Components minimizes let rec as much as possible, using Tarjan's strongly connected components algorithm which someone else was nice enough to already have implemented. The container runs this algorithm on submitted programs. In conjunction with the improved let generalization, this means you can submit larger Unison programs to the container as a giant let rec block, building up whatever polymorphic functions you need for your "main" expression. Your helper functions / prelude will be generalized like you'd expect, and you don't have to worry about ordering your bindings manually.

pchiusano added some commits Aug 5, 2016

Merge remote-tracking branch 'origin/topic/node-container' into topic…

# Conflicts:
#	node/unison-node.cabal

@pchiusano pchiusano merged commit 61899d7 into topic/node-container Aug 12, 2016

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
continuous-integration/travis-ci/push The Travis CI build passed

@pchiusano pchiusano deleted the topic/node-container-main branch Aug 12, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment