Found 42 bookmarks
Custom sorting
Rob Napier’s Swift/Haskell post
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.
·robnapier.net·
Rob Napier’s Swift/Haskell post
SE-0156’s note about merging `class` and `AnyObject` reference-type existentials
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).
·github.com·
SE-0156’s note about merging `class` and `AnyObject` reference-type existentials
Swift Generics Evolution - don’t panic
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.
·timekl.com·
Swift Generics Evolution - don’t panic
History: Why does closure syntax use the keyword `in`?
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...
·forums.swift.org·
History: Why does closure syntax use the keyword `in`?
Custom string delimiters
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…
·ericasadun.com·
Custom string delimiters
On labeled tuples versus structs
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.”
·mobile.twitter.com·
On labeled tuples versus structs
Nested Mapping
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
·mobile.twitter.com·
Nested Mapping
Custom Ternary Operators in Swift
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.
·natecook.com·
Custom Ternary Operators in Swift
Seemingly Impossible Swift Programs
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.
·fewbutripe.com·
Seemingly Impossible Swift Programs