Swift format style reference
Raw Strings in Swift
A reference work of how raw strings work in Swift
SwiftDocOrg/GraphViz
A Swift package for working with GraphViz. Contribute to SwiftDocOrg/GraphViz development by creating an account on GitHub.
Olivier Halligon’s property wrapper talk.
The “Some More Inspiration” slide is great. https://speakerdeck.com/alisoftware/and-thats-a-wrap?slide=23
A Type System from Scratch
swift/Tuple.swift.gyb’s `==` definition for empty tuples and up to arity 6
The Swift Programming Language. Contribute to apple/swift development by creating an account on GitHub.
A Generic Deriving Mechanism for Haskell
Guessing Swift takes a similar approach in [SE-0185](https://github.com/apple/swift-evolution/blob/098152eafbfbd7faa74d81e1443231bd7caabc45/proposals/0185-synthesize-equatable-hashable.md).
API Pollution in Swift Modules
When you import a module into Swift code, you expect the result to be entirely additive. But as we’ll see, this isn’t always the case.
Rob Napier’s Swift/Haskell post
A paradigm is sneaking in when you aren’t paying attention. Pay attention. There’s a chance here to influence development practice for decades We really can have languages that give the benefits of tomorrow without losing all the working components of today. I think Swift can be one of those languages. Much of that, I believe, is education.
SE-0156’s note about merging `class` and `AnyObject` reference-type existentials
Whenever I mentally parse `protocol SomeProtocol: SomeOtherProtocol`, it’s meant to imply `SomeProtocol` adds additional requirements onto another protocol, namely `SomeOtherProtocol`’s. What’s odd about class-constraining protocols is that it’s been a weird historical inconsistency in Swift where the term to the right of the `:` _isn’t_ a protocol and instead a reserved word. All reference types implicitly conform to `AnyObject`, which, being a protocol, makes it a more consistent way of class constraining than remembering the special `: class` trick. This merging of concepts was lightly mentioned in [SE-0156](https://github.com/apple/swift-evolution/blame/93abb54833e2d9ee7ee842882f6104a867de3069/proposals/0156-subclass-existentials.md#L134) (link to specific line).
An implementation of `Func.dimap`
The intuition here is pre-composing on the input and post-composition on the output.
`any` and `some` duality
This maintains proposals for changes and user-visible enhancements to the Swift Programming Language. - swift-evolution/proposals/0244-opaque-result-types.md at b1caeccf5d273a1cc53b331d41ea169f7729...
Applicatives in Swift
Swift Generics Evolution - don’t panic
it’s reassuring to know that the folks driving changes in Swift have a solid background in language design, and that they’re thinking about all manner of hard problems in order to make our lives easier. However, it makes me worry that people might be missing out on a truly exciting conversation about what might be coming in a future Swift version. The reason for the label “reverse generics” is that the flow of information is backwards from the existing system. Where right now, the caller binds generic types as it calls a function, the proposal would have the function itself bind the return types and pass concrete values back out.
Enums as configuration: the anti-pattern
One of the most common patterns I see in software design with Objective-C (and sometimes Swift), is the use of enumeration types (enum) as configurations for...
“Enums are for switching. If you aren’t going to switch over a value—outside of the type—then use a struct.”
“Enums are for switching. If you aren’t going to switch over a value—outside of the type—then use a struct.”
History: Why does closure syntax use the keyword `in`?
It's my fault, sorry. In the early days of Swift, we had a closure syntax that was very similar to traditional Javascript, func (arg: Type, arg: Type) -> Return { ... }. While this is nice and regular syntax, it is of course also very bulky and awkward if you're trying to support expressive functional APIs, such as map/filter on collections, or if you want libraries to be able to provide closure-based APIs that feel like extensions of the language. Our earliest adopters at Apple complained about...
Handling nested types named `Type`
Backticks ('`Type`') are another good alternative (that I keep forgetting exists). pic.twitter.com/ILz3ODm07V— Ole Begemann (@olebegemann) January 30, 2019
Lenses in Swift
objcio/swift-talk-backend
Contribute to objcio/swift-talk-backend development by creating an account on GitHub.
On needing to “ground the type” when asking about a generic typealias and Tagged
“@jasdev @mbrandonw We still need to bind Outer to something to use it at a call site and ground the type. Any remaining generic allows us to create different types, like Email and Email, which might be totally what we want! But they’re diff types.”
The Automatic Differentiation Manifesto
Hi all, I wrote an Automatic Differentiation Manifesto, as the start to push for world's first general-purpose differentiable programming language.
Pullbacks’ influence on the Automatic Differentiation Manifesto
“Look up pullbacks in differential geometry and you will find the image on the left. Look up pullbacks in category theory and you will find the image on the right, which generalizes everything in one diagram. That is the type of generality that libraries should strive for.”
Custom string delimiters
Say, for whatever reason, you were in desperate need of Bill the Cat ASCII art in your app. Maybe you were very drunk and had a bet. Maybe you were working with some kind of Unix awk client. I dunn…
On labeled tuples versus structs
“@jckarter @Javi @mdiep The space of things that are typey enough to need labels but not typey enough to get a name and call a struct is pretty small.”
Modeling Your View Models as Functions
At Grailed we’ve turned to functional programming for inspiration on how to write testable, well-structured view models.
Nested Mapping
“Free map functions express the nesting nicely: map: ((A) -> B) -> (Signal) -> Signal map: ((A) -> B) -> ([A]) -> [B] Then the nested map is function composition: (map < map): ((A) -> B) -> (Signal
Custom Ternary Operators in Swift
Even though Swift only supports unary and binary operators for operator overloading, it's possible to implement our *own* ternary operators by declaring two separate operators that work together and using a *curried function* for one of the operators.
Seemingly Impossible Swift Programs
I begin to feel that I can trust mathematics as a guiding beacon for how programming can be done well. This is why I feel strongly that simple mathematical constructs, like pure functions, monoids, etc., form a strong foundation of abstraction as opposed to the overly complicated, and often ad-hoc, design patterns we see in software engineering. I spend a lot of my time trying to find new and creative ways to bring seemingly complex functional programming ideas down to earth and make them approachable to a wider audience. but it does give us an opportunity to explore a strange and surprising result in computation and mathematics. It can help show that the connection between the two topics is perhaps deeper than we may first think.
Result in Swift 5
Result in Swift 5