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
protocol CanBark { | |
func bark() -> String | |
} | |
class Animal { | |
func animalType() -> String { | |
return "Animal" | |
} | |
} |
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
// this is a playground | |
protocol Nat { | |
class func construct() -> Self | |
class func value() -> Int | |
} | |
struct Z : Nat { | |
static func construct() -> Z { | |
return Z() | |
} |
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
// Playground - noun: a place where people can play | |
protocol ℕ { | |
static func construct() -> Self | |
static var value : UInt { get } | |
} | |
struct Zero : ℕ { | |
static func construct() -> Zero { | |
return Zero() |
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
protocol Monad { | |
typealias F | |
typealias U | |
class func bind<M : Monad where M.U == U>(Self, F -> M) -> M | |
class func `return`(F) -> Self | |
} | |
extension Array : Monad { | |
typealias F = T |