From 5e947046a3483b270db077e5ba77994cc6110733 Mon Sep 17 00:00:00 2001 From: Keagan McClelland Date: Wed, 14 Aug 2024 18:25:35 -0700 Subject: [PATCH] fn: breaking - give Result's FlatMap proper functor annotation --- fn/result.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fn/result.go b/fn/result.go index 9f4dc1a6c..15118c66d 100644 --- a/fn/result.go +++ b/fn/result.go @@ -173,9 +173,9 @@ func (r Result[T]) OrElse(f func() Result[T]) Result[T] { return f() } -// FlatMap applies a function that returns a Result[B] to the success value if -// it exists. -func FlatMap[A, B any](r Result[A], f func(A) Result[B]) Result[B] { +// FlatMapResult applies a function that returns a Result[B] to the success +// value if it exists. +func FlatMapResult[A, B any](r Result[A], f func(A) Result[B]) Result[B] { if r.IsOk() { return f(r.left) } @@ -186,7 +186,7 @@ func FlatMap[A, B any](r Result[A], f func(A) Result[B]) Result[B] { // AndThen is an alias for FlatMap. This along with OrElse can be used to // Railway Oriented Programming (ROP). func AndThen[A, B any](r Result[A], f func(A) Result[B]) Result[B] { - return FlatMap(r, f) + return FlatMapResult(r, f) } // LiftA2Result lifts a two-argument function to a function that can operate