Are you tired of being pushed around by inversion of control?

It's time to ...

Take Back Control

Take Back Control (TBC) is a library for writing event-driven code in a style that uses standard control structures.

A number of demos can be found below.

Learn more here.

New notation.

Since the first Blog posts were written, the >> operator has been deprecated in favour of >=, which can now take a guard as its left operand, and the && operator has been deprecated in favour of >> which can now take a guard as its left operand too. Similarly for guards, the .guarding method is deprecated in favour of .bing and the .andThen method is deprecated in favour of the (new) .sc method. Furthermore guards can now be used anywhere that guarded processes are used. A guard is simply a guarded process that does nothing and outputs the event.

Assuming that the following variables have the type indicated,

VariableType
g1, g2Guard<A>
gp1. gp2GuardedProcess<A>
p1Process<A>
p2Process<B>
f A -> Process<B>
c A -> Bool
lf (Void -> Process<A>) -> Process<A>
r Void -> Process<A>

then the following expressions make sense and have the type indicated.

ExpressionMethod notationType
g1 & c g1.filter( c ) Guard<A>
g1 >= f g1.bind( f ) Process<B>
gp1 >= f gp1.bind( f ) Process<B>
p1 >= f p1.bind( f ) Process<B>
g1 > p2 g1.sc( p2 ) GuardedProcess<B>
gp1 > p2 gp1.sc( p2 ) GuardedProcess<B>
p1 > p2 p1.sc( p2 ) Process<B>
g1 || g2 g1.orElse( g2 ) GuardedProcess<A>
gp1 || g2 gp1.orElse( g2 ) GuardedProcess<A>
g1 || gp2 g1.orElse( gp2 ) GuardedProcess<A>
gp1 || gp2 gp1.orElse( gp2 ) GuardedProcess<A>
await( g ) Process<A>
await( gp1 ) Process<A>
loop( p1 ) Process<Triv>
fix( lf ) Process<A>
repeat( r ) Process<A>

Demos

GIT