Skip to content

Instantly share code, notes, and snippets.

View r-peck's full-sized avatar

Ryan Peck r-peck

  • Atlassian
  • Austin, TX
View GitHub Profile
@r-peck
r-peck / Inference.swift
Created June 10, 2019 20:32
Inferring nested associated types with opaque return types
protocol A { }
struct AImpl: A {
init() { }
}
protocol B {
associatedtype BA: A
var a: BA { get }
@r-peck
r-peck / SwiftUI+Reader.swift
Last active June 6, 2019 23:07
Layering Reader on top of SwiftUI
// started from https://gist.github.com/chriseidhof/f6d9b42c709a83413e84cafc0f7295cd
import SwiftUI
import Combine
struct Reader<R, A> {
public let run: (R) -> A
public static func pure(_ a: A) -> Reader<R, A> {
return Reader<R, A> { _ in a }
struct Hole<T> {
static var value: T {
fatalError("Unfilled hole of type `\(String(describing: T.self))`")
}
}
enum Result<T, E: Error> {
case success(T)
case failure(E)
### Keybase proof
I hereby claim:
* I am r-peck on github.
* I am ryanpeck (https://keybase.io/ryanpeck) on keybase.
* I have a public key whose fingerprint is 18A5 26D3 7296 9175 9DD6 3345 68EC 2FE0 CD84 1547
To claim this, I am signing this object: