I'm getting a `StackOverflowError` sometimes becau...
# arrow
r
I'm getting a
StackOverflowError
sometimes because my `bind()`'s inside
fx.monad
go pretty deep (too deep, apparently). Are there any simple ways to restructure my code to work around this, or do I just need to rewrite it differently? This usually works fine as a quick way to do validation, but it seems to break down at large scales.
Copy code
fun <F> MonadError<F, String>.layerGraphIsValid(
    layerGraph: Graph<SealedLayer.MetaLayer>
): Kind<F, Unit> =
    fx.monad {
        layerNamesAreUnique(layerGraph).bind()
        layerGraph.nodes().forEach {
            hasInputs(it).bind()
            inputsAreDeclared(layerGraph, it).bind()
        }
    }