You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You may have noticed that the parameters of optics composition are the inverse of function composition. Optics composition looks more like andThen than compose.
defandThen[A, B, C](f: A=>B, g: B=>C):A=>C
Therefore, I propose to create a new overloaded method andThen and deprecate all thecomposeX methods later.
For example for lenses will have something like:
traitPLens[S, T, A, B] {
defandThen[C, D](other: PLens[A, B, C, D]):PLens[S, T, C, D] =???defandThen[C, D](other: PPrism[A, B, C, D]):POptional[S, T, C, D] =???defandThen[C, D](other: PIso[A, B, C, D]):PLens[S, T, C, D] =???// and so on
}
I propose to overload andThen instead of using andThenLens, andThenPrism for a few reasons:
it is more concise
users don't need to think about what type of optics they are composing
the main reason to have non-overloaded compose methods is to help type inference for optics like at, index, each which I think we can get away by adding shortcuts on each optic Add shortcut for at #956
If this works well, we can deprecate all composeLens, composePrism, ... methods.
The text was updated successfully, but these errors were encountered:
Optics and functions compose in the same way
You may have noticed that the parameters of optics composition are the inverse of function composition. Optics composition looks more like
andThen
thancompose
.Therefore, I propose to create a new overloaded method
andThen
and deprecate all thecomposeX
methods later.For example for lenses will have something like:
I propose to overload
andThen
instead of usingandThenLens
,andThenPrism
for a few reasons:at
,index
,each
which I think we can get away by adding shortcuts on each optic Add shortcut for at #956If this works well, we can deprecate all
composeLens
,composePrism
, ... methods.The text was updated successfully, but these errors were encountered: