Using Free Monads to Simplify Workflows

Check back soon for scheduling!

At Wyatt Technology one of our products is used to run workflows during pharmaceutical production. These workflows monitor analytical instruments and control pump hardware, as well as integrating with the rest of the customer's production control system. Our first cut at implementing one of these workflows resulted in a thousand lines of state machine code that was a convoluted mess of nested matches on nested discriminated unions. While some of the code was reusable for other workflows, it was very much not clear how to extract it into a reusable form. Enter free monads and computation expressions. Using this technique we were able create a system of reusable building blocks that make it easy to write understandable workflow code (with dramatically reduced line counts). Error handling, pause/resume, and state saving/restoring is factored out so that it doesn't complicate the workflow code itself. In this workshop I'll show how to create a system of this sort.

About Brett Hall

Brett Hall

Principal Software Engineer at Wyatt Technology