@@ -967,8 +967,11 @@ string_to_varname(str::AbstractString) = dict_to_varname(JSON.parse(str))
967
967
968
968
Get the innermost layer of an optic.
969
969
970
+ For all (normalised) optics, we have that `normalise(_tail(optic) ∘
971
+ _head(optic) == optic)`.
972
+
970
973
!!! note
971
- Does not perform optic normalisation. You may wish to call
974
+ Does not perform optic normalisation on the input . You may wish to call
972
975
`normalise(optic)` before using this function if the optic you are passing
973
976
was not obtained from a VarName.
974
977
@@ -999,8 +1002,11 @@ _head(::typeof(identity)) = identity
999
1002
1000
1003
Get everything but the innermost layer of an optic.
1001
1004
1005
+ For all (normalised) optics, we have that `normalise(_tail(optic) ∘
1006
+ _head(optic) == optic)`.
1007
+
1002
1008
!!! note
1003
- Does not perform optic normalisation. You may wish to call
1009
+ Does not perform optic normalisation on the input . You may wish to call
1004
1010
`normalise(optic)` before using this function if the optic you are passing
1005
1011
was not obtained from a VarName.
1006
1012
@@ -1031,8 +1037,11 @@ _tail(::typeof(identity)) = identity
1031
1037
1032
1038
Get the outermost layer of an optic.
1033
1039
1040
+ For all (normalised) optics, we have that `normalise(_last(optic) ∘
1041
+ _init(optic)) == optic`.
1042
+
1034
1043
!!! note
1035
- Does not perform optic normalisation. You may wish to call
1044
+ Does not perform optic normalisation on the input . You may wish to call
1036
1045
`normalise(optic)` before using this function if the optic you are passing
1037
1046
was not obtained from a VarName.
1038
1047
@@ -1063,8 +1072,11 @@ _last(::typeof(identity)) = identity
1063
1072
1064
1073
Get everything but the outermost layer of an optic.
1065
1074
1075
+ For all (normalised) optics, we have that `normalise(_last(optic) ∘
1076
+ _init(optic)) == optic`.
1077
+
1066
1078
!!! note
1067
- Does not perform optic normalisation. You may wish to call
1079
+ Does not perform optic normalisation on the input . You may wish to call
1068
1080
`normalise(optic)` before using this function if the optic you are passing
1069
1081
was not obtained from a VarName.
1070
1082
@@ -1084,7 +1096,9 @@ identity (generic function with 1 method)
1084
1096
julia> AbstractPPL._init(Accessors.@o _)
1085
1097
identity (generic function with 1 method)
1086
1098
"""
1087
- _init (o:: ComposedFunction{Outer,Inner} ) where {Outer,Inner} = _init (o. outer) ∘ o. inner
1099
+ # This one needs normalise because it's going 'against' the direction of the
1100
+ # linked list (otherwise you will end up with identities scattered throughout)
1101
+ _init (o:: ComposedFunction{Outer,Inner} ) where {Outer,Inner} = normalise (_init (o. outer) ∘ o. inner)
1088
1102
_init (:: Accessors.PropertyLens ) = identity
1089
1103
_init (:: Accessors.IndexLens ) = identity
1090
1104
_init (:: typeof (identity)) = identity
0 commit comments