This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Monoid | |
precedencegroup MonoidPrecedence { | |
associativity: left | |
} | |
infix operator <> : MonoidPrecedence | |
protocol Monoid { | |
static var empty: Self { get } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct AnyEncodable: Encodable { | |
let base: Encodable | |
init(_ value: Encodable) { | |
base = value | |
} | |
func encode(to encoder: Encoder) throws { | |
try base.encode(to: encoder) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension Notification { | |
struct TypedName<Value> { | |
let rawValue: String | |
init(_ rawValue: String) { | |
self.rawValue = rawValue | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension String { | |
init<T>(dumping x: T) { | |
self.init() | |
dump(x, to: &self) | |
} | |
} | |
func assertDumpsEqual<T>(_ lhs: @autoclosure () -> T, _ rhs: @autoclosure () -> T, file: StaticString = #file, line: UInt = #line) { | |
assert(String(dumping: lhs()) == String(dumping: rhs()), "Expected dumps to be equal.", file: file, line: line) | |
} |
NewerOlder