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 XCPlayground | |
import UIKit | |
let collectionCellId = "CollectionCell" | |
func newCollectionView() -> UICollectionView { | |
let layout = UICollectionViewFlowLayout() | |
layout.itemSize = CGSize(width: 250, height: 300) | |
layout.scrollDirection = .Horizontal | |
let collectionView = UICollectionView(frame: CGRect(x: 0, y:0, width: 300, height: 500), collectionViewLayout: layout) |
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
enum Freer<V, M, MV> { | |
case Pure(V) | |
case Impure(M, MV->Freer<V, M, MV>) | |
func flatMap<U>(f:V -> Freer<U, M, MV>) -> Freer<U, M, MV> { | |
switch self { | |
case .Pure(let v): | |
return f(v) | |
case .Impure(let v, let k): | |
return .Impure(v, { newV in |
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
typealias Disposable = () -> Void | |
protocol StoreType { | |
associatedtype StateType | |
associatedtype ActionType | |
var state:StateType { get } | |
func dispatch(action:ActionType) | |
func subscribe(subscriber:(StateType)->Void) -> Disposable | |
} |
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
// (State, Action) -> State | |
class Store<State, Action> { | |
typealias Reducer = (State, Action) -> State | |
typealias Subscriber = State -> Void | |
typealias Disposable = () -> Void | |
private(set) var state: State | |
private let reducer:Reducer | |
private var subscribers:[Subscriber?] = [] |
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
// originally from https://gist.github.com/cobbal/7562875ab5bfc6f0aed6 | |
protocol Monad { | |
associatedtype V // Value Type | |
associatedtype U // Constraint Type | |
func bind<M : Monad where M.U == U>(f: V -> M) -> M | |
static func just(unit: V) -> Self | |
} | |
extension Monad { |
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 | |
let dictionary: NSDictionary = [ | |
"env": [ | |
"address": "Home" | |
], | |
"setting": [ | |
"up": "Hello", | |
"spnining": false |
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
func const<A, B>(value:A) -> B -> A { | |
return { _ in value } | |
} | |
func f<T: Equatable>(o: Optional<T> -> [T], i: T) -> Optional<T> -> [T] { | |
return { optional in | |
if optional == i { | |
return o(optional) | |
} | |
return o(i) + [i] |
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 Async<T> { | |
let execution: (T->Void, ErrorType->Void) -> Void | |
static func unit(value:T) -> Async<T> { | |
return Async { $0.0(value) } | |
} | |
} | |
infix operator >>= { associativity left } | |
func >>=<A, B>(f: A->Async<B>, a:Async<A>) -> Async<B> { |
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
[{ | |
"name": "Hello, World" | |
}] |
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
XCODEUUID=`defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID` | |
for f in ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins/*; do defaults write "$f/Contents/Info" DVTPlugInCompatibilityUUIDs -array-add $XCODEUUID; done |