July 30, 2018

Why Monads?

There’s some talk going on in the Swift Forums about whether it could be useful or not to add the notion of Higher-Kinded Types (from now on, HKTs) to the Swift’s type system. This discussion has been going for a while in the Swift community, and there seems to be a lack of practical examples to sustain the need for such an advanced feature. Unfortunately, HKTs are in the area of things that become obvious if you have them and use them every day, but tend to remain obscure if you have to work without them: that’s because HKTs can shift one’s way of thinking about programming, abstractions and computation in general. ... Read more

March 19, 2018

Algebraic data types for contextual and conditional computation

An algebraic data type (ADT from now on) is a type (class, struct, enum, whatever the language allows us) that has no intrinsic semantics, and only exists for combining two or more other types in a specific way. For example, in Swift the tuple (Int,String) is an ADT, in the sense that the only information it conveys is the fact that one instance of it will contain one instance of Int and one instance of String. ... Read more

November 19, 2017

Lenses and Prisms in Swift: a pragmatic approach

This is a new version of an old article about lenses and prisms in Swift. This one contains many updates and more precisely reflects how I actually use these things in my work. This is also based on a talk I gave at iOSDevUK 2017 and Mobilization Conference 2017. I’m keeping the old article in draft as reference. In date Sep 8 2018 I modified the article further, by including Affine in the discussion, again to reflect my current work better. ... Read more

September 9, 2017

On Abstraction

This post is a direct answer to this other post, which itself is mostly an answer to a bunch of discussions on Twitter, talks and more posts. While this post has probably value by itself, it’s probably better to read the original post first, because I’m going to refer to some of its statements. There’s an interesting discussion going in the functional Swift community: whether using abstract data types, like Monoid, is actually useful, and how this relates to the way protocols are usually laid out in the standard library. ... Read more

© Elviro Rocca 2018