git.iko.soy/typeable/schematic
on master help sign in
Update changelog and readme
commit1076b561e924c2e2236f15d174e25226e2a0b92a authorDenis Redozubov <denis.redozubov@gmail.com> dateWed 23 Aug 2017, 12:29 (9 years ago) parent483aebf
2 files changed+26
ChangeLog.md+5 README.md+21
ChangeLog.md+5
@@ -1,5 +1,10 @@
11# Revision history for schematic
22
3+
4+## 0.1.5.0 -- 2017-08-22
5+
6+Lens compatibility for typed json objects.
7+
38## 0.1.0.0 -- YYYY-mm-dd
49
510* First version. Released on an unsuspecting world.
README.md+21
@@ -110,3 +110,24 @@ It's possible to decode the latest version like this:
110110```
111111decodeAndValidateJson schemaJsonTopVersion :: ParseResult (JsonRepr (TopVersion (AllVersions VS)))
112112```
113+
114+## Lens-compatibility
115+
116+It's possible to use `flens` to construct a field lens for a typed object in schematic. Let's suppose you have a schema like this:
117+
118+```
119+type ArraySchema = 'SchemaArray '[AEq 1] ('SchemaNumber '[NGt 10])
120+
121+type ArrayField = '("foo", ArraySchema)
122+
123+type FieldsSchema =
124+ '[ ArrayField, '("bar", 'SchemaOptional ('SchemaText '[TEnum '["foo", "bar"]]))]
125+
126+type SchemaExample = 'SchemaObject FieldsSchema
127+
128+```
129+
130+There are two ways of working with named fields in the objects:
131+
132+* Using the `fget` and `fset` functions: `fget fooProxy (fput newFooVal objectData) == newFooVal`
133+* Using the lens library: `set (flens (Proxy @"foo")) newFooVal objectData ^. flens (Proxy @"foo") == newFooVal`