blob: daa7065a2bf6a7b395314756b51f807ae7893905 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
package cc.spray.json
package lenses
trait Operations {
def set[T: JsonWriter](t: T): Operation = new Operation {
def apply(value: SafeJsValue): SafeJsValue =
// ignore existence of old value
Right(t.toJson)
}
trait MapOperation extends Operation {
def apply(value: JsValue): SafeJsValue
def apply(value: SafeJsValue): SafeJsValue = value.flatMap(apply)
}
def updated[T: MonadicReader : JsonWriter](f: T => T): Operation = new MapOperation {
def apply(value: JsValue): SafeJsValue =
value.as[T] map (v => f(v).toJson)
}
def append(update: Update): Operation = ???
def update(update: Update): Operation = ???
def extract[M[_], T](value: Projection[M])(f: M[T] => Update): Operation = ???
}
object Operations extends Operations
|