epfl-lara / stainless

Verification framework and tool for higher-order Scala programs
https://epfl-lara.github.io/stainless/
Apache License 2.0
349 stars 49 forks source link

Add Monadic Try construct to the Stainless library #1515

Closed samuelchassot closed 2 months ago

samuelchassot commented 2 months ago

An inline version of the flatMap function works well, but only with Dotty, not scalac.

inline def flatMap[U](inline f: T => Try[U]): Try[U] = this match {
      case Success(t) => f(t)
      case Failure(exc: Exception) => Failure(exc)
    }