TOC
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
import Foundation | |
let mark = Array(repeating: "-", count: 40).joined(separator: "") | |
func chapter(s: String, line: Int = #line) { print("\n", "// " + mark, "// \(s) - line: \(line)", "// " + mark, separator: "\n")} | |
func section(s: String, line: Int = #line) { print("", "~~ \(s)", separator: "\n")} | |
func assertEqual<A: Equatable>(_ a: A, _ b: A) { assert(a == b); print(a, "==", b) } | |
// ---------------------------------------------------------------------------------------------- | |
// It`s a generic type of world | |
// | |
// http://elm4ward.github.io/swift/generics/mocking/dependency/injection/2016/05/21/generic-dependency-mocking.html |
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
let mark = Array(repeating: "-", count: 40).joined(separator: "") | |
func chapter(_ s: String, line: Int = #line) { print("\n", "// " + mark, "// \(s) - line: \(line)", "// " + mark, separator: "\n")} | |
func section(_ s: String, line: Int = #line) { print("\n", "# \(s)", mark, separator: "\n")} | |
import struct CoreGraphics.CGFloat | |
// ---------------------------------------------------------------------------------------------------- | |
// MARK: - Bi-directional Type Inference | |
// | |
// http://elm4ward.github.io/swift/generics/type/inference/2016/05/01/bidirectional.html |
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
let mark = "####################################" | |
let chapter: (String) -> Void = { print("\n", mark, "# \($0)", mark, separator: "\n")} | |
// ---------------------------------------------------------------------------------------------------- | |
// MARK: - Look ma, no protocols | |
// | |
// http://elm4ward.github.io/swift/generics/type/erasure/2016/04/21/erase-em-all.html | |
// | |
// Erasing generics to life in freedom | |
// This is a follow up to the article about Protocols with Typealias |
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
// ---------------------------------------------------------------------------------------------------- | |
// Iterators for Naysayer | |
// | |
// Generating understandable, reusable, simplified, ... code with Iterators | |
// | |
// http://elm4ward.github.io/swift/Iterator/protocol/2016/04/14/Iterators-for-the-naysayers.html | |
// | |
// 1. Base Protocols | |
// 2. ZipWithSum | |
// 3. ZipWithSumFrom |
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
import UIKit | |
import PlaygroundSupport | |
import Foundation | |
import CoreGraphics | |
// ---------------------------------------------------------------------------------------------------- | |
// MARK: - Interpolations | |
// | |
// http://elm4ward.github.io/swift/generator/protocol/2016/04/08/Interpolations.html | |
// |
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
// ---------------------------------------------------------------------------------------------------- | |
// MARK: - Lazy comonadic array zipper | |
// | |
// http://elm4ward.github.io/swift/functional/comonad/2016/04/06/da-lazy-one.html | |
// | |
// Stacking functions lazily can speed up your code. | |
// | |
// 1. The struct | |
// 2. Lazy in action | |
// ---------------------------------------------------------------------------------------------------- |
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 Flow in Swift | |
// | |
// http://elm4ward.github.io/swift/protocols/2016/04/02/protocollisions.html | |
// | |
// 1. The Protocols | |
// 2. The Flow | |
// 3. String Example | |
// 4. Custom Example | |
// ---------------------------------------------------------------------------------------------------- |
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
// ---------------------------------------------------------------------------------------------------- | |
// ArrayZipper Comonads in Swift | |
// | |
// http://elm4ward.github.io/swift/functional/comonad/2016/03/30/monads-comonads.html | |
// | |
// 1. Array extensions | |
// 2. ArrayZipperError | |
// 3. ArrayZipper | |
// 4. ArrayZipper extensions | |
// 5. custom operators |
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
/// the protocol | |
protocol ImplicitDefault { | |
static var implicitDefault: Self { get } | |
} | |
/// the implementation for Strings | |
extension String: ImplicitDefault { | |
/// i dont care i take the empty string as default |