This is a useful cache for memoizing function.
This is a useful cache for memoizing function.
The cache is implemented using a mutable pointer to an immutable map value. In the worst-case, race conditions might cause us to lose cache values (i.e. compute some keys twice), but we will never produce incorrect values.
Represents a directed acyclic graph (DAG).
Represents a directed acyclic graph (DAG).
The type N[_] represents the type of nodes in the graph.
Expr[N, T] is an expression of a graph of container nodes N[_] with result type N[T].
Expr[N, T] is an expression of a graph of container nodes N[_] with result type N[T]. These expressions are like the Literal[T, N] graphs except that functions always operate with an indirection of a Id[T] where N[T] is the type of the input node.
Nodes can be deleted from the graph by replacing an Expr at Id = idA with Var(idB) pointing to some upstream node.
To add nodes to the graph, add depth to the final node returned in a Unary or Binary expression.
TODO: see the approach here: https://gist.github.com/pchiusano/1369239 Which seems to show a way to do currying, so we can handle general arity
This is a Natural transformation.
This is a Natural transformation.
For any type X, this type can produce a function from T[X] to R[X].
This is a useful cache for memoizing natural transformations.
This is a useful cache for memoizing natural transformations.
The cache is implemented using a mutable pointer to an immutable map value. In the worst-case, race conditions might cause us to lose cache values (i.e. compute some keys twice), but we will never produce incorrect values.
This is a weak heterogenous map.
This is a weak heterogenous map. It uses equals on the keys, so it is your responsibilty that if k: K[_] == k2: K[_] then the types are actually equal (either be careful or store a type identifier).
The Expressions are assigned Ids.
The Expressions are assigned Ids. Each Id is associated with an expression of inner type T.
This is done to put an indirection in the Dag that allows us to rewrite nodes by simply replacing the expressions associated with given Ids.
T is a phantom type used by the type system
This represents literal expressions (no variable redirection) of container nodes of type N[T]
Often a partial function is an easier way to express rules
This implements a simplification rule on Dags
Collection of graph algorithms