git.iko.soy/typeable/schematic
on master help sign in
Update changelog and readme
1076b56Denis Redozubov
ChangeLog.md+5
@@ -1,5 +1,10 @@
1# Revision history for schematic
1# Revision history for schematic
2
2
3+
4+## 0.1.5.0 -- 2017-08-22
5+
6+Lens compatibility for typed json objects.
7+
3## 0.1.0.0 -- YYYY-mm-dd
8## 0.1.0.0 -- YYYY-mm-dd
4
9
5* First version. Released on an unsuspecting world.
10* First version. Released on an unsuspecting world.
README.md+21
@@ -110,3 +110,24 @@ It's possible to decode the latest version like this:
110```
110```
111decodeAndValidateJson schemaJsonTopVersion :: ParseResult (JsonRepr (TopVersion (AllVersions VS)))
111decodeAndValidateJson schemaJsonTopVersion :: ParseResult (JsonRepr (TopVersion (AllVersions VS)))
112```
112```
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`