@@ -16,15 +16,6 @@ trait can be evaluated directly at any object.
16
16
"""
17
17
abstract type Transform end
18
18
19
- """
20
- assertions(transform)
21
-
22
- Returns a list of assertion functions for the `transform`. An assertion
23
- function is a function that takes an object as input and checks if the
24
- object is valid for the `transform`.
25
- """
26
- function assertions end
27
-
28
19
"""
29
20
isrevertible(transform)
30
21
@@ -51,6 +42,15 @@ See also [`isrevertible`](@ref).
51
42
"""
52
43
function isinvertible end
53
44
45
+ """
46
+ assertions(transform)
47
+
48
+ Returns a list of assertion functions for the `transform`. An assertion
49
+ function is a function that takes an object as input and checks if the
50
+ object is valid for the `transform`.
51
+ """
52
+ function assertions end
53
+
54
54
"""
55
55
prep = preprocess(transform, object)
56
56
@@ -80,19 +80,16 @@ function revert end
80
80
"""
81
81
newobject = reapply(transform, object, cache)
82
82
83
- Reapply the `transform` to (a possibly different) `object` using a `cache`
84
- that was created with a previous [`apply`](@ref) call.
83
+ Reapply the `transform` to (a possibly different) `object`
84
+ using a `cache` that was created with a previous [`apply`](@ref)
85
+ call. Fallback to [`apply`](@ref) without using the `cache`.
85
86
"""
86
87
function reapply end
87
88
88
89
# --------------------
89
90
# TRANSFORM FALLBACKS
90
91
# --------------------
91
92
92
- assertions (transform:: Transform ) =
93
- assertions (typeof (transform))
94
- assertions (:: Type{<:Transform} ) = []
95
-
96
93
isrevertible (transform:: Transform ) =
97
94
isrevertible (typeof (transform))
98
95
isrevertible (:: Type{<:Transform} ) = false
@@ -101,8 +98,13 @@ isinvertible(transform::Transform) =
101
98
isinvertible (typeof (transform))
102
99
isinvertible (:: Type{<:Transform} ) = false
103
100
101
+ assertions (transform:: Transform ) = []
102
+
104
103
preprocess (transform:: Transform , object) = nothing
105
104
105
+ reapply (transform:: Transform , object, cache) =
106
+ apply (transform, object) |> first
107
+
106
108
(transform:: Transform )(object) =
107
109
apply (transform, object) |> first
108
110
0 commit comments