promenade
Take program design oddities in stride with Clojure/ClojureScript.
Rationale
Non-trivial Clojure applications often need to deal with deeply nested conditions, complex error handling and potentially missing data. Naively applying Clojure's facilities to such problems may lead to brittle code that is hard to reason about. This library provides few basic mechanisms to decouple the tangled concerns.
Goals
- Provide facilities to take apart code units and put back together in a cleaner way
- Provide simple & effective API without the awkwardness of using monads in Clojure
- Keep the surface area of this library's API small, fun and easy to work with
Non goals
- Be faithful implementation of monads
- Adapt all known monads (completeness)
- Be limited to monadic ideas
Implemented features
- Decouple condition checks from conditional action by representing success and failure (called Either)
- Represent and deal with available and missing values (called Maybe)
- Avoid imperativeness and coupling of throwing and catching of exceptions (called Trial)
Other work
You may find similarities to this library in the following work:
External references
- IN/Clojure 2018 talk: Elegant error-handling for a more civilized age and Slides by Varun Sharma
- Blog post: Using Clojure macros for nicer error handling by Jake McCrary
Usage
See Documentation
Discuss
Slack channel: #promenade (you need an invitation from http://clojurians.net/ to join the Clojurian Slack team)
Development
Running tests:
$ lein do clean, test # run tests in lowest supported Clojure version
$ lein do clean, clj-test # run tests in all supported versions of Clojure
$ lein do clean, cljs-test # run tests in ClojureScript using NodeJS
License
Copyright © 2017-2021 Shantanu Kumar
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.