There's a pattern in my code (Java) which looks like:
private M<State2> augmentFromDS3(M<State1> state1) {
return state1.flatMap(this::transform1);
}
private M<State3> validatePersonType1(M<State2> state2) {
return state2.flatMap(this::transform2);
}
private M<State2>
transform1(State1 state1) {
}
private M<State3>
transform2(State2 state2) {
}
There's also a version which calls map.
This feels like there's a functional pattern (like a monad transformer, comonad, etc.) here that has been found before. However, I don't know what the name is for the kind of thing I think is there.
答案 0 :(得分:3)
通过查看问题的标题,我认为这是Haskell(或Scala中的flatMap)中monad的bind(>> =)函数:
(>>=) :: m a -> (a -> m b) -> m b