This is a curated list of iOS (Swift & ObjC) frameworks which are inspired by React and Elm.
- ReactSwift by @ColinEberhardt
- https://github.com/ColinEberhardt/ReactSwift
| // | |
| // ViewController.swift | |
| // Forms | |
| // By Brandon Kase and Chris Eidhof | |
| import UIKit | |
| protocol Element { | |
| associatedtype Input |
| // This example shows how higher-kinded types can be emulated in Swift today. | |
| // It acheives correct typing at the cost of some boilerplate, manual lifting and an existential representation. | |
| // The technique below was directly inspired by the paper Lightweight Higher-Kinded Polymorphism | |
| // by Jeremy Yallop and Leo White found at http://ocamllabs.io/higher/lightweight-higher-kinded-polymorphism.pdf | |
| /// `ConstructorTag` represents a type constructor. | |
| /// `Argument` represents an argument to the type constructor. | |
| struct Apply<ConstructorTag, Argument> { | |
| /// An existential containing a value of `Constructor<Argument>` | |
| /// Where `Constructor` is the type constructor represented by `ConstructorTag` |
This is a curated list of iOS (Swift & ObjC) frameworks which are inspired by React and Elm.
| protocol Expr { | |
| static func lit(_ x: Int) -> Self | |
| static func add(_ lhs: Self, _ rhs: Self) -> Self | |
| } | |
| extension Int : Expr { | |
| static func lit(_ x : Int) -> Int { | |
| return x; | |
| } | |
| static func add(_ lhs: Int, _ rhs: Int) -> Int { |
| extension RawRepresentable where Self: Hashable { | |
| private static func iterateEnum<T: Hashable>(_: T.Type) -> AnyIterator<T> { | |
| var index = 0 | |
| let closure: () -> T? = { | |
| let next = withUnsafePointer(to: &index) { | |
| $0.withMemoryRebound(to: T.self, capacity: 1) { $0.pointee } | |
| } | |
| guard next.hashValue == index else { return nil } |
| public struct AnyEquatable: Equatable { | |
| private let value: Any | |
| private let equals: Any -> Bool | |
| public init<E: Equatable>(_ value: E) { | |
| self.value = value | |
| self.equals = { ($0 as? E == value) ?? false } | |
| } | |
| } |
| // | |
| // Free.swift | |
| // Swift_Extras | |
| // | |
| // Created by Robert Widmann on 9/19/14. | |
| // Copyright (c) 2014 Robert Widmann. All rights reserved. | |
| // | |
| import Foundation |