Created
July 16, 2016 06:51
-
-
Save 53ningen/b0a0607013d994779a27f5e7b2ddcb4b to your computer and use it in GitHub Desktop.
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
/// `* -> *` | |
public class K1<A> { public init() {} } | |
public protocol Functor { | |
associatedtype A | |
associatedtype B | |
associatedtype FB = K1<B> | |
func fmap(f : A -> B) -> FB | |
} | |
extension Array : Functor { | |
public typealias A = Element | |
public typealias B = Any | |
public typealias FB = [B] | |
public func fmap<B>(f : A -> B) -> [B] { | |
return self.map(f) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment