Git Product home page Git Product logo

tsd's Introduction

TSD

An Ocaml implementation of Transparent Synchronous Dataflow

Requirements

  1. Ocaml 4.05.0 +
  2. oasis2opam package
  3. In order to run the benchmarks for ReactiveML and JaneStreet Incremental Library, please make sure the following are installed.

Installation

  1. To pin and install the TSD package, run make install and follows the instruction.
  2. To uninstall, run make uninstall

Compilation

Run ocamlfind ocamlc -package tsd,tsd.ppx -o $TARGET -linkpkg $SOURCE to compile your favourite programs.

Examples and Benchmarks

  1. To build all the examples, simply run make examples. The compiled executable can be found in examples/build/$TARGET/$TARGET.
  2. To execute the benchmarks, simply run make benchmarks.

Running on utop

  1. Run #ppx "tsd_ext";;
  2. Run #require "tsd";;
  3. Run open Tsd;;
  4. Try running let x = [%dfg 1];; and it should work!

The TSD language extension and helper functions

An extensive description of the language and the underlying calculus can be found in the report Transparent Synchronous Dataflow. Here is a quick recap:

  • val peek : 'a graph -> 'a : takes a node in a graph, evaluates it, and returns its value
  • val root : 'a graph -> 'a graph : returns the dependencies of a cell (if it is not a cell it gives a runtime error)
  • val cell : 'a graph -> 'a graph : takes a node in a graph as argument and returns a new cell dependent on the node
  • val link : 'a graph -> 'a graph -> unit : takes a cell and a node and makes the node the (new) dependency of the cell (if the first argument is not a cell it gives a runtime error)
  • val (<~) : 'a graph -> 'a graph -> unit : alias for link
  • val assign : 'a graph -> 'a -> unit : change the value of a cell (runtime error if argument not a cell)
  • val (<:=) : 'a graph -> 'a -> unit : alias for assign
  • val set : 'a graph -> 'a -> unit : combination of link and assign
  • val (<:~) : 'a graph -> 'a -> unit : alias for set
  • val init : unit -> unit : deletes the dataflow graph
  • val step : unit -> bool : propagates changes until every cell is changed at most once. It returns true if changes were made.

The tag [%dfg t] always returns a node in a graph that corresponds to t. Note that this node is not a cell. For example let x = [%dfg 1] creates a constant graph with node 1. This let f = [%dfg fun x y -> x * y] creates a function from graphs to graphs which can be used as follows:

let ( * ) = lift ( * );;
let f = [%dfg fun x y -> x * y];;
let x = cell [%dfg 1] ;;
let y = cell [%dfg 2] ;;
let m = [%dfg f x y];;

This creates a dataflow graph with two cells, initialised to 1 and 2, connected via multiplication to the node x (which is not a cell).

tsd's People

Contributors

cwtsteven avatar danghica avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

danghica graydon

tsd's Issues

cannot run basic example

utop # let f = [%dfg fun x y -> x * y];;
val f : (float -> float -> float) graph =
─( 13:12:16 )─< command 13 >─────────────────────────────────────{ counter: 0 }─
utop # let x = f (cell [%dfg 1]) (cell [%dfg 2]);;
Line 1, characters 8-9:
Error: This expression has type (float -> float -> float) Tsd.graph
This is not a function; it cannot be applied.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.