Release |
---|
Arrow and Symmetric Monoidal Category composition syntax helper
Lets say you have type Process[Input, Output]
, you want to use process comprehensions for your type
- Define volga.Arr or volga.Symon instance for your type
- Import syntax extensions
import volga.syntax.comp._ import volga.syntax.cat._ import volga.syntax.symon._ // or import volga.syntax.arr._
- Prepare syntax composer for your type
or
val process = arr[Process]
whereval process = symon[Process, Pair, One]
Pair
andOne
are tensor product type constructor and unit type for your Symon instance - write your arrows
val myProcess: Process[Pair[Pair[A, B], C], Pair[D, E]] = process{ (a, b, c) => val (x, y) = someProcess1(a, b) val z = someProcess2(c, x) ---- val d = someProcess3() someProcess4(y) val e = someProcess5(z) (d, e) }
-
comprehension for arrow
proc: (X1, X2, ...) -> (Y1, Y2, ...)
or monoidal morpshism (note left assiciativity of products)
proc: (Tensor(...(Tensor(X1, X2), ...) -> Tensor(...Tensor(Y1, Y2),..)
should form a lambda function having parameters of types
(V[X1], V[X2], ...) =>
-
last line in comprenension defined in 1.
should be in form
(y1, y2, ...)
or non-assigning applicationsomeProcess(z1, z2, ...)
wheresomeProcess
is an arrowproc: (Z1, Z2, ...) -> (Y1, Y2, ...)
or monoidal morpshism (note left assiciativity of products)
proc: (Tensor(...(Tensor(Z1, Z2), ...) -> Tensor(...Tensor(Y1, Y2),..)
-
to use some arrow
proc: (X1, X2, ...) -> (Y1, Y2, ...)
or monoidal morpshim (note left assiciativity of products)
proc: (Tensor(...(Tensor(X1, X2), ...) -> Tensor(...Tensor(Y1, Y2),..)
you can write
val (y1, y2, ...) = proc(x1, x2, ...)
-
non-assigning construction
proc(x1, x2, ...)
could be used to dispose result of arrow, or use morphism with unit domain
-
special block-separator
----
could be used to enforce the end of parallel block