47 Degrees joins forces with Xebia read more

Bow 0.5.0 is now available

Bow 0.5.0 is now available

In our constant effort to make Bow the best companion library for Functional Programming in Swift, we are announcing a release. Version 0.5.0 focuses on three key aspects: providing an increasingly complete API for the core module, a fully revamped optics module, and a set of utilities for Property-based Testing that are exposed for end-users and used internally to ensure the correctness of what the library provides. Keep reading for a better idea of the features that this release includes.

More complete API in the core module

As part of this release, we’ve been comparing the data types that we offer as part of the core module in Bow, with those in the Arrow library for Kotlin. Although the needs of each library are different, there are some common data types that we need to include. We spent time reviewing and completing the set of provided methods in our core data types to make sure you get the methods you are looking for when you use these types. We’ve also included some type class instances for some of the core types were missing.

Optics

Most of our efforts have been focused on the optics module. This module provides a set of utilities that let you handle and manipulate complex nested immutable data structures seamlessly.

However, working with optics involves writing some boilerplate to get the optic that you need to do the task you are interested in completing. We know boilerplate can hinder your adoption of this module; that’s why we have provided automatic generation of a few optics as part of this release. In many cases, by leveraging the usage of key paths (a feature that was introduced in Swift 4), we can provide an automatic implementation of the optic you need.

For the cases where this is not possible, we have provided a set of utilities that, using composition, will let you get the optic you need, with little effort. From lenses focused on components to tuples to traversals over collections of values, you will be able to find the low-level components you need for your data types.

Type classes for optics have also received a lot of attention in this release. They have been completely rewritten following the same style that was applied to the core module in version 0.4.0 so that their instances are automatically resolved. This results in a much simpler API that is easier to consume by end-users.

Finally, all the work that’s been completed in this module has been documented. The API reference of this module is available in the API reference section of the site. Moreover, we have included a section in the documentation that specifically addresses optics where you can read how to create your own optics for your data types, derive them automatically, and compose different optics to achieve your task.

Property-based Testing

For us, it is crucial that the utilities we provide in Bow work as expected. To ensure this, we use a technique called Property-based Testing that lets us test the properties of the data types and type classes that we provide in the various modules of Bow. The library SwiftCheck enables us to do this.

An essential part of this technique is being able to generate random values of a data type to feed the properties that are being checked. In Bow 0.5.0, we provide generators for each data type included in each module. These generators are also used in the internal tests of the library and have helped us catch a few bugs in older versions of the library.

Outside of the new modules that include generators for Property-based Testing, we are releasing the laws that are used to check that the implementation of the instances of type classes that we provide is correct. Therefore, if you need to create your own data type and provide instances for some type classes, you can easily test them using the modules included in Bow 0.5.0.

Conclusions

There are additional improvements in the library, as well as the site, like the recently added version selector that lets you verify what version you’re using and find the documentation, or, review what updated releases hold. Speaking of which, we have continued adding documentation to the API reference; more than 80% of the symbols in the Bow API are now documented.

Bow continues to mature, and this release contributes substantially to its stabilization. If you want to learn more about it, make sure to follow our recently launched campaign on Twitter under the hashtag #BowShots, where we showcase small snippets of code, generated with nef, that go through some of the data types of the core module.

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.