fn: breaking - rename ChainOption to FlatMapOption for consistency

This commit is contained in:
Keagan McClelland 2024-08-14 18:26:20 -07:00
parent 5e947046a3
commit dd7f1569c7
No known key found for this signature in database
GPG Key ID: FA7E65C951F12439
2 changed files with 5 additions and 5 deletions

View File

@ -133,11 +133,11 @@ func FlattenOption[A any](oo Option[Option[A]]) Option[A] {
return oo.some return oo.some
} }
// ChainOption transforms a function A -> Option[B] into one that accepts an // FlatMapOption transforms a function A -> Option[B] into one that accepts an
// Option[A] as an argument. // Option[A] as an argument.
// //
// ChainOption : (A -> Option[B]) -> Option[A] -> Option[B]. // FlatMapOption : (A -> Option[B]) -> Option[A] -> Option[B].
func ChainOption[A, B any](f func(A) Option[B]) func(Option[A]) Option[B] { func FlatMapOption[A, B any](f func(A) Option[B]) func(Option[A]) Option[B] {
return func(o Option[A]) Option[B] { return func(o Option[A]) Option[B] {
if o.isSome { if o.isSome {
return f(o.some) return f(o.some)

View File

@ -383,7 +383,7 @@ func TestPropLastTailIsLast(t *testing.T) {
return true return true
} }
return Last(s) == ChainOption(Last[uint8])(Tail(s)) return Last(s) == FlatMapOption(Last[uint8])(Tail(s))
} }
require.NoError(t, quick.Check(f, nil)) require.NoError(t, quick.Check(f, nil))
@ -396,7 +396,7 @@ func TestPropHeadInitIsHead(t *testing.T) {
return true return true
} }
return Head(s) == ChainOption(Head[uint8])(Init(s)) return Head(s) == FlatMapOption(Head[uint8])(Init(s))
} }
require.NoError(t, quick.Check(f, nil)) require.NoError(t, quick.Check(f, nil))