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 | |
| protocol Lens { | |
| associatedtype ParentType | |
| associatedtype ChildType | |
| func lget(_ parent: ParentType) -> ChildType | |
| func lset(_ parent: ParentType, _ child: ChildType) -> ParentType | |
| } |
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 | |
| protocol LensProtocol { | |
| func lget(data: Any?) -> Any?; | |
| func lset(data: Any?, val: Any?) -> Any?; | |
| } |
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
| from pprint import pprint | |
| from copy import copy | |
| class KeyLens(object): | |
| def __init__(self, key): | |
| self.key = key | |
| def lget(self, data): | |
| return data[self.key] |
NewerOlder