47 Degrees joins forces with Xebia read more

Bow 0.6.0 is now available

Bow 0.6.0 is now available

Writing functional code entails coding functions that are total (defined for every possible input), deterministic (produce same output for a given input), and pure (the only observed effect is computing the returned value). However, programs need to produce side effects in order to have a meaningful purpose, which seems to contradict the previous definition. How can we reconcile both things?

Today, we are releasing Bow 0.6.0, which aims to address this problem with a revamped Bow Effects module. This module includes utilities to suspend side effects using the IO data type, and work with them asynchronous and concurrently while maintaining and enforcing purity. Keep reading to know more about what this release includes.

Bow Effects

Bow already included a module to work with effects in previous versions; although it had utilities to suspend side effects and run them in a controlled manner, it lacked important features for a full-fledge working module. This release includes a more complete type class hierarchy that describes capabilities to defer computations that produce side effects; work with asynchronous computations; and perform concurrent operations, combining their results.

Those type classes are materialized in the IO<E, A> data type. This data type models a suspended computation that produces side effects and returns a value of type A, or produces an error of type E. Note that it allows us to be explicit about the error type that may happen in an IO computation. IO can be run synchronously or asynchronously in order to actually produce its effects, and provides an important number of combinators to transform both the value and error types, or chain dependent computations, among others.

In addition to IO, Bow Effects provides an EnvIO<D, E, A>, inspired by the Scala library ZIO. It lets us have scoped effects that depend on an environment of type D. When we need to run the computation, we need to provide a value of such type in order to satisfy its requirements. Bow Effects also provides some aliases for cases where we don’t want to be explicit about the error type (resorting to the generic Error) or when we have unfailable computations (resorting to the Never type to model errors).

Streams and RxSwift

The type classes provided in the Bow Effects module are not only materialized in the IO data type. Bow also includes an integration with the popular streaming library RxSwift. It wraps the main three data types that are provided by the library: SingleK, MaybeK, and ObservableK. These wrappers let us use the types with the Higher Kinded Type emulation system provided by Bow, and provide instances for all relevant type classes in the Functor hierarchy, and in the newly introduced Effects hierarchy.

Monad Comprehensions

The other important improvement that we have included in this release is Monad comprehensions. Monad comprehensions let us work with monadic effects using imperative-like syntax and avoiding nested flatMap calls. Bow Effects besides adds sugared instructions to switch the dispatch queue where the computations are being executed, or to run them in parallel.

Growing documentation

As with the latest releases, we have invested an important amount of effort in providing the API reference documentation of the newly released modules, as well as writing their corresponding entry pages in the documentation to give you examples of how to use the library. The API reference covers around 90% of the library at the moment of this release, and we will continue adding content to the documentation to ease the learning curve of the library.


This release closes a cycle of improvements that started with a massive refactor of the library to have better HKT emulation in version 0.4.0, and a big improvement of the Optics module in version 0.5.0.

Version 0.6.0 provides a highly necessary module to deal with side effects. Together with the new syntax for Monad comprehensions, it gives tremendous expressive power to developers. Writing functional code in Swift is more and more becoming a pleasant experience as Bow advances in its maturity process.

Please check out the following Bow resources. Comments and questions are welcome and encouraged!

Bow is proudly sponsored by 47 Degrees, a Functional Programming consultancy with a focus on the Scala, Kotlin, and Swift Programming languages which supports the active development of Bow.

Ensure the success of your project

47 Degrees can work with you to help manage the risks of technology evolution, develop a team of top-tier engaged developers, improve productivity, lower maintenance cost, increase hardware utilization, and improve product quality; all while using the best technologies.