The Composable Architecture (TCA, pour faire court) est une bibliothèque permettant de construire des applications de manière cohérente et compréhensible, en tenant compte de la composition, des tests et de l'ergonomie. Elle peut être utilisée avec SwiftUI, UIKit, et encore, et sur toutes les plateformes Apple (iOS, ma
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
/* | |
In Computer Science class I was tasked with writing a function takes a raw CSV table and returns a list of OrderedDictionaries and vice versa – but in Python. | |
It felt messy, convoluted and slow, so I wanted to what it would look like in Swift, especially with Pointfree's swift-parsing library and their experimental parser-builder branch. | |
This is as high performance as possible while using the swift-parsing library. Consequently, this doesn't support special characters such as é or æ due to the use of UTF8 code units. | |
*/ | |
import Algorithms | |
import OrderedCollections | |
import Parsing |
This file contains hidden or 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 BinaryInteger { | |
@inlinable | |
var isOdd: Bool { | |
return withUnsafePointer(to: self & 1) { pointer in | |
return UnsafeRawPointer(pointer) | |
.bindMemory(to: Bool.self, capacity: 1) | |
.pointee | |
} | |
} |
This file contains hidden or 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 PredicateSet<Element: Equatable> { | |
var contains: (Element) -> Bool | |
init(_ contains: @escaping (Element) -> Bool) { | |
self.contains = contains | |
} | |
} | |
extension PredicateSet: SetAlgebra { | |
init() { |
This file contains hidden or 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
/// Property wrapper to introduce indirection into your property. | |
/// | |
/// Indirection is very useful to introduce recursion into `structs`, which don't usually support it. This is very similar to using the `indirect` modifier on enum cases. | |
/// | |
/// struct Person: Identifiable { | |
/// let id = UUID() | |
/// | |
/// @Indirect var father: Person? | |
/// @Indirect var mother: Person? | |
/// } |
This file contains hidden or 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
protocol Copyable { | |
func copy() -> Self | |
} | |
/// A protocol for value types which gives them copy-on-write behaviour. This means that when multiple variables are pointing to the type, they point to the same underlying data to avoid excessive copying. When one of them modifies the type, it copies the type, therefore keeping value semantics. | |
@dynamicMemberLookup | |
protocol CopyOnWrite { | |
associatedtype Storage: AnyObject & Copyable | |
/// The underlying storage of the type, which is a reference type. |
This file contains hidden or 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
/// Simple protocol which types who want to implement builder pattern conform to for free – gives conforming types two simple functions for building | |
protocol Buildable {} | |
extension Buildable { | |
/// Returns a new instance whose property defined by the keypath is set to `value`. | |
/// - Parameters: | |
/// - keyPath: `WriteableKeyPath` to the property which shall be modified | |
/// - value: The value which will be set to the property | |
/// | |
/// This function is used for types with value semantics. |