whenIs

open fun <T> whenIs(yes: (Solution.Yes) -> T? = null, no: (Solution.No) -> T? = null, halt: (Solution.Halt) -> T? = null, otherwise: (Solution) -> T = { throw IllegalStateException("Cannot handle solution $it") }): T

Exhaustively (or partially) pattern-matches this Solution against its three possible subtypes, invoking whichever of yes/no/halt corresponds to this solution's actual kind, or otherwise if that branch was left null (by default, throwing IllegalStateException).