Archaeopterix, KissClipArt.com

Let’s evolve the Dyno library for AWS DynamoDB to use Apple’s new SwiftUI and Combine libraries. We’ll also eliminate our dependency on Python and so end up with a library we can use on iOS (and other Apple platforms) as well macOS. We’ll end up with a much tighter, Swift-only library with no external dependencies.

In this article, we’ll rebuild Dyno as a fully async DynamoDB interface library, using pure Swift. On the way we learn about Combine, Publishers, how to test asynchronous code, Cryptokit, AWS services and authentication… and a special One More Thing at the end!

The code…


minmisaur / pdclipart.org

In the last two articles we’ve been building up a library to communicate with Amazon’s DynamoDB database, by using their boto3 library. On the way, we’ve explored how well Python integrates with Swift, and started building a Reactive interface to allow results to be returned to the end user.

We’ve got more to do though:

  • build a reactive user interface which will automatically display our results
  • caching to deal with failed or slow connections.

Now, however, we need to pause before we build more functionality, and add some tests so that we can be sure future changes don’t break our…


Last time, we did a lot of setup to get started with Amazon Web Services’ DynamoDB, including using the Swift-Python bridge so we could use the official AWS interface boto3 to communicate with DynamoDB.

But boto3 has several limitations, aside from being Python-based and hence without Swift type-safety : it’s complex, difficult to use — and has a major problem that it is synchronous.

To see the problem, run the code we arrived at last time:


Update: the second article in this series is now available!

openclipart.com

Dyno is a new Swift library under construction to:

Provide a functional, Reactive, safe and easy-to-use interface to the Amazon AWS DynamoDB database.

Don’t worry if that doesn’t make much sense — or if it makes sense but doesn’t sound useful for you — because as well as practical steps I’ll also be discussing ideas and techniques which will hopefully be adaptable elsewhere.

Along the way, it will:

  • integrate the official AWS Python boto3 libraries with Swift
  • add robust, async handling
  • output data via an reactive Observable stream
  • provide RxSwift…


Chinese calligraphy / openclipart.com

In the last article, I spent some time looking at Monads — data structures which provide a function called bind or flatMap (or >>>=). Monads provide us with a powerful new way to combine functions.

I then spent a bit of time trying to gain an intuition for what a Monad is.

Finally, we saw that Optionals, Arrays and WebData types are all Monads (and defined bind for them).

In this article, I’m going to cover a lot of ground, looking at some examples of Monads that we don’t often see in Swift (or at least, that are not often…


Source: British Library / openclipart.com

So far we have looked at some powerful tools with the HKT framework — Functors and Applicative Functors. We’re going to go one step further in this article and look at the most powerful tool yet — Monads.

Then, we’ll look at some examples of Monads, including Arrays, Optionals and WebData. A companion article to this will look at some more: Writers, Readers and Futures.

Check out the Github page for more!

Transforming WebData 🔰

We’re going to continue the example from last time, and talk about WebData<A> which represents a value we get from the internet (eg, someone entered it into a…


Oregon Trail map, freeclipart.com

In this post, I’m going to talk about something we don’t hear much about in Swift: applicative functors. These let us perform some very powerful operations with a minimum of code.

This is using an extended, and simplified, version of the HKT (Higher Kinded Type) framework I introduced last time . We looked at Functors in Swift: to recap, Functors are “containers” (like Sequences such as Array or a LinkedList) which have a superpowered map called fmap that transforms the container’s contents but leaves the container itself intact. …


Sequences and Collections in Swift are an incredibly powerful way to build complex functionality from composable, functional pieces. I try to use them as much as I can; but they do have an interesting limitation I ran into when building machine learning algorithms in Swift.

Here’s some code:


Pixabay/Creative Commons

Inspired by Apple’s Core ML and Michael Nielsen’s fantastic online book on machine learning, I thought I’d try and understand the basics of the algorithms, and explore Swift 4, by rewriting the Python code from Nielsen’s book into Swift.

We’ll tackle the machine learning algorithms in a further blog, but the most immediate problem I ran into was matrix manipulation in Swift. Python has the numpy library; and although there are some good versions of this for Swift on GitHub, nothing quite met what I wanted. Specifically, I was looking for something expressive, functional (in the best sense of the…

Jonathan @ Strictly Swift

The world, Swifter

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store