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 edited

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
@pchiusano pchiusano WIP on node container main 4fed2a7
@pchiusano pchiusano Finished initial stab at container main, with scotty front-end 0f63fea
@pchiusano pchiusano progress submitting a program to container 9527b17
@pchiusano pchiusano add spawn builtin, hack to allow contacting non-existent nodes 9380875
@pchiusano pchiusano logging, fixed hang when launching worker process due to buffering of…
… IPC pipe
@pchiusano pchiusano WIP on getting container main working 718fd1d
@pchiusano pchiusano Merge remote-tracking branch 'origin/topic/node-container' into topic…

# Conflicts:
#	node/unison-node.cabal
@pchiusano pchiusano added let handling to interpreter aaefe7a
@pchiusano pchiusano effect blocks syntax 8f8fb53
@pchiusano pchiusano fix parser 8d00369
@pchiusano pchiusano add tests for effect block parser 06685bd
@pchiusano pchiusano workers now do typechecking, fixed race condition where worker could …
…receive a message before being subscribed
@pchiusano pchiusano more logging statements; fixed deadlock where worker output packets w…
…ere sitting idle in OS buffer
@pchiusano pchiusano fix bug with Mux.runStandardIO sending Packet rather than Maybe Packe…
…t on output
@pchiusano pchiusano more bugfixes edaa373
@pchiusano pchiusano Merge remote-tracking branch 'origin/topic/node-container' into topic…
@pchiusano pchiusano fix bug in container that was causing dropped packets 8d727c2
@pchiusano pchiusano fix issue with noop crypto pipes; all keys padded out to 32 bytes now 98bf8ab
@pchiusano pchiusano using sync packet to make sure pipeResponder is listening 1bcac72
@pchiusano pchiusano more bugfixes; round trip appears to be working 64e9d4b
@pchiusano pchiusano bit of cleanup 8caec42
@pchiusano pchiusano revamp of logging, which now uses Unison.Util.Logger, dynamically con…
…figured via configurator
@pchiusano pchiusano logging improvements and some cleanup ac901a5
@pchiusano pchiusano fix Mux.subscribeTimed to return Nothing rather than just bomb on tim…
@pchiusano pchiusano fix possible bug in subscribeTimed 682b5a8
@pchiusano pchiusano fix bug in Multiplex.request functions that would result in callbacks…
… not being removed from map
@pchiusano pchiusano tweak logging levels 2f69829
@pchiusano pchiusano adding tests of interpreter 56ed8be
@pchiusano pchiusano Added booleans and numeric comparison functions, more Interpreter tests a202f27
@pchiusano pchiusano fix type of numeric comparison functions, add (failing) test of let rec a1b8bb7
@pchiusano pchiusano fix for let rec, but still a problem with mutual recursion df2cb7a
@pchiusano pchiusano fix let rec interpretation for mutually recursive functions fbc9720
@pchiusano pchiusano beef up test 5b9b635
@pchiusano pchiusano added some simple let generalization, cleanup 8930909
@pchiusano pchiusano now using Tarjan's algo for strongly connected components, which is i…
…ntegrated into node container eval
@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