Skip to content

Commit 59cddc8

Browse files
committed
add flatMap to JSEither
1 parent 3b160c6 commit 59cddc8

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

js/src/main/scala/gov/irs/factgraph/monads/JSEither.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ enum JSEither[+A, +B] {
3737
case Left(e) => lf(e)
3838
case Right(v) => rf(v)
3939

40-
// TODO: All of the other useful methods for monads are TK
40+
@JSExport
41+
def flatMap[C](f: js.Function1[B, JSEither[A, C]]): JSEither[A, C] = this match
42+
case Right(v) => f(v)
43+
case Left(v) => this.asInstanceOf[JSEither[A, C]]
4144

45+
// TODO: All of the other useful methods for monads are TK
4246
}

0 commit comments

Comments
 (0)