Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pipelines with error handling in Clojure

I'm looking for a smart way to create composable validation and transformation pipelines in Clojure. The aim is to be able to do simple translation and validation of messages using composable steps.

Main requirements:

  • Can be composed functionally, i.e. pipelines are pure functions
  • Can be applied to regular Clojure data types (maps, vectors, lists, and nested combinations thereof)
  • Can perform transformations, e.g. renaming a key in map
  • Can perform arbitrary validations (e.g. applying a Schema validation to part of a message)
  • Can bail out gracefully when errors are detected, and return a meaningful error message (not just throwing an exception!)

I guess I can write all this, but don't particularly feel like reinventing the wheel today :-)

Dopes anyone know of a tool that can do this, or have a good idea regarding how to construct one in a clever and general way?

like image 534
mikera Avatar asked Feb 04 '14 03:02

mikera


1 Answers

You might look at Zach Tellman's Lamina library. You can create pipelines of functions with error handlers as other useful functionality.

like image 112
Alex Miller Avatar answered Nov 07 '22 09:11

Alex Miller