I'm writing a lot of code like the following:
popStack groupTail
|> andThen
(\( parentGroup, parentTail ) ->
addChild currentGroup sibling
|> andThen
(\updatedParent ->
case sibling of
SingleExercise _ ->
workHelp siblingIndent (updatedParent :: parentTail)
WorkGroup _ _ ->
workHelp siblingIndent (sibling :: (updatedParent :: parentTail))
)
)
It feels a lot like callback hell with all the nested andThen calls, and I was wondering if there are idiomatic ways to use different kinds of function application to avoid all the nesting.