Skip to content

Instantly share code, notes, and snippets.

import UIKit
protocol Lens {
associatedtype ParentType
associatedtype ChildType
func lget(_ parent: ParentType) -> ChildType
func lset(_ parent: ParentType, _ child: ChildType) -> ParentType
}
import UIKit
protocol LensProtocol {
func lget(data: Any?) -> Any?;
func lset(data: Any?, val: Any?) -> Any?;
}
@phronmophobic
phronmophobic / lens.py
Last active April 7, 2019 22:54
python lens
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]