@@ -52,7 +52,7 @@ the library rely on their combinatorial semantics to allow declarative ideas to
5252be expressed more clearly in Swift.
5353
5454Swiftz is a proper superset of [ Swiftx] ( https://github.com/typelift/Swiftx ) that
55- implements higher-level data types like Lenses, Zippers , HLists, and a number of
55+ implements higher-level data types like Arrows, Lists , HLists, and a number of
5656typeclasses integral to programming with the maximum amount of support from the
5757type system.
5858
@@ -112,11 +112,6 @@ public class User : JSONDecodable {
112112 <*> x <? " tweets"
113113 <*> x <? " attrs" <> " one" // A nested keypath
114114 }
115-
116- // lens example
117- public class func luserName () -> Lens<User, User, String , String > {
118- return Lens { user in IxStore (user.name ) { User ($0 , user.age , user.tweets , user.attr ) } }
119- }
120115}
121116
122117public func == (lhs : User, rhs : User) -> Bool {
@@ -129,55 +124,7 @@ let userjs = "{\"name\": \"max\", \"age\": 10, \"tweets\": [\"hello\"], \"attrs\
129124//: the user would be nil.
130125let user : User? = JSONValue.decode (userjs) >>- User.fromJSON // .Some( User("max", 10, ["hello"], "1") )
131126```
132-
133- ** Lenses**
134-
135- ``` swift
136- import struct Swiftz .Lens
137- import struct Swiftz .IxStore
138-
139- //: A party has a host, who is a user.
140- final class Party {
141- let host : User
142-
143- init (h : User) {
144- host = h
145- }
146-
147- class func lpartyHost () -> Lens<Party, Party, User, User> {
148- let getter = { (party : Party) -> User in
149- party.host
150- }
151-
152- let setter = { (party : Party, host : User) -> Party in
153- Party (h : host)
154- }
155-
156- return Lens (get : getter, set : setter)
157- }
158- }
159-
160- //: A Lens for the User's name.
161- extension User {
162- public class func luserName () -> Lens<User, User, String , String > {
163- return Lens { user in IxStore (user.name ) { User ($0 , user.age , user.tweets , user.attrs ) } }
164- }
165- }
166-
167- //: Let's throw a party now.
168- let party = Party (h : User (" max" , 1 , [], Dictionary ()))
169-
170- //: A lens for a party host's name.
171- let hostnameLens = Party.lpartyHost () • User.luserName ()
172-
173- //: Retrieve our gracious host's name.
174- let name = hostnameLens.get (party) // "max"
175-
176- //: Our party seems to be lacking in proper nouns.
177- let updatedParty = (Party.lpartyHost () • User.luserName ()).set (party, " Max" )
178- let properName = hostnameLens.get (updatedParty) // "Max"
179- ```
180-
127+
181128** Semigroups and Monoids**
182129
183130``` swift
0 commit comments