47 Degrees joins forces with Xebia read more

Announcing Bow Lite 0.1

Announcing Bow Lite 0.1

Over the course of almost three years, we have focused on developing Bow, a library enabling typed Functional Programming in Swift. One of the most prominent features of this library is the emulation of lightweight Higher Kinded Types, using a variation of the proposal in the paper Lightweight Higher-Kinded Polymorphism by Jeremy Yallop and Leo White. This has allowed us to reach a new level of what’s possible to abstract using Swift’s type system. We have been able to introduce type classes in the Functor hierarchy that are otherwise impossible to represent using vanilla Swift. Furthermore, we have been able to build the powerful library Bow Arch that is highly polymorphic and lets us replace different effect types to yield new architectures; something that wouldn’t even be possible with the level of polymorphism that we can achieve normally on Swift.

However, as we have been presenting the library in multiple user groups, we have noticed that many of these notions were too advanced for newcomers to Functional Programming, and that was a hindrance in the adoption of Bow. In some cases, you have to be aware of what HKTs are and how they are emulated in order to know how to use the library. The learning curve may not be optimal in these cases.

We have acknowledged that, and tried to provide a solution where you can practice Functional Programming in Swift, while minimizing the advanced concepts you need to know in order to use it. Today, we are announcing Bow Lite.

Lightweight FP in Swift

Bow Lite is a reduced version of Bow with the core types that you will use in most of the applications. We have not included the emulation of HKTs, and consequently, we weren’t able to include the type class hierarchy; but this does not mean you can’t use its power. All included types provide the same methods available in Bow–you just can’t abstract over them. It’s a tradeoff between being able to write more generic, polymorphic code, and having an easier learning curve. And, in Bow Lite, we want to emphasize the latter.

API compatibility

Another key aspect of the library is that we have tried to keep the APIs of Bow and Bow Lite as compatible as possible. This is not 100% possible due to the fact that we have HKT emulation in Bow. But, if you start using Bow Lite, and, at some point in the future, decide to jump into Bow, the amount of changes that you will need to make should be minimal. We will follow up with a new version of Bow, where we will bring some enhancements and increase the API compatibility between both libraries.

Modules

Bow Lite includes a pretty complete core module with the data types that you will be using in most projects. Besides that, it includes a module to control side effects, and another one to work with deeply nested data structures using optics. We have observed that these three pillars (Core, Effects, and Optics) are what we use most, and wanted to make them available to you. Nonetheless, you will only need to import Bow Lite to have all three at your disposal.

Conclusion

We think Bow Lite is a nice resource for newcomers to Functional Programming, as its learning curve should be smoother than with Bow, while, at the same time, all lessons learned can be applied when deciding to jump into Bow. You can easily try both, Bow and Bow Lite, on your iPad using nef Playgrounds, where you will be able to generate a Swift Playground with the contents of the library.

We will be using Bow Lite in our upcoming course on Fundamentals of Functional Programming in Swift with Bow, which is offered at 50% discounted price. We encourage you to join and enjoy the journey through FP with us! Meanwhile, give the library a try and let us know your impressions!

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

Bow, and its ecosystem, is proudly sponsored by 47 Degrees, a Functional Programming consultancy with a focus on the Scala, Kotlin, Swift, and Haskell Programming languages supporting 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.