diff --git a/fn/either_test.go b/fn/either_test.go index dca15f8d9..81af2bc6c 100644 --- a/fn/either_test.go +++ b/fn/either_test.go @@ -100,16 +100,14 @@ func TestPropToOptionIdentities(t *testing.T) { e = NewRight[int, string](s) r2O := e.RightToOption() == Some(s) - o2R := e == OptionToRight[string, int, string]( - Some(s), i, - ) + o2R := e == OptionToRight(Some(s), i) l2O := e.LeftToOption() == None[int]() return r2O && o2R && l2O } else { e = NewLeft[int, string](i) l2O := e.LeftToOption() == Some(i) - o2L := e == OptionToLeft[int, int](Some(i), s) + o2L := e == OptionToLeft(Some(i), s) r2O := e.RightToOption() == None[string]() return l2O && o2L && r2O diff --git a/fn/fn.go b/fn/fn.go index 147bf7daf..ea9190b7f 100644 --- a/fn/fn.go +++ b/fn/fn.go @@ -23,7 +23,7 @@ func Iden[A any](a A) A { // Const is a function that accepts an argument and returns a function that // always returns that value irrespective of the returned function's argument. // This is also quite useful in conjunction with higher order functions. -func Const[A, B any](a A) func(B) A { +func Const[B, A any](a A) func(B) A { return func(_ B) A { return a } diff --git a/fn/option.go b/fn/option.go index 57245a9ba..656be264d 100644 --- a/fn/option.go +++ b/fn/option.go @@ -216,7 +216,7 @@ func (o Option[A]) UnsafeFromSome() A { // OptionToLeft can be used to convert an Option value into an Either, by // providing the Right value that should be used if the Option value is None. -func OptionToLeft[O, L, R any](o Option[O], r R) Either[O, R] { +func OptionToLeft[O, R any](o Option[O], r R) Either[O, R] { if o.IsSome() { return NewLeft[O, R](o.some) } @@ -226,7 +226,7 @@ func OptionToLeft[O, L, R any](o Option[O], r R) Either[O, R] { // OptionToRight can be used to convert an Option value into an Either, by // providing the Left value that should be used if the Option value is None. -func OptionToRight[O, L, R any](o Option[O], l L) Either[L, O] { +func OptionToRight[O, L any](o Option[O], l L) Either[L, O] { if o.IsSome() { return NewRight[L, O](o.some) } @@ -239,7 +239,7 @@ func OptionToRight[O, L, R any](o Option[O], l L) Either[L, O] { // and Some is converted to Ok. func (o Option[A]) SomeToOk(err error) Result[A] { return Result[A]{ - OptionToLeft[A, A, error](o, err), + OptionToLeft(o, err), } } @@ -248,7 +248,7 @@ func (o Option[A]) SomeToOk(err error) Result[A] { // ignored and Some is converted to Ok. func (o Option[A]) SomeToOkf(errString string, args ...interface{}) Result[A] { return Result[A]{ - OptionToLeft[A, A, error](o, fmt.Errorf(errString, args...)), + OptionToLeft(o, fmt.Errorf(errString, args...)), } } diff --git a/fn/slice_test.go b/fn/slice_test.go index fae9bd361..18f7602ad 100644 --- a/fn/slice_test.go +++ b/fn/slice_test.go @@ -427,7 +427,7 @@ func TestSingletonInitIsEmpty(t *testing.T) { // empty slice. func TestPropAlwaysNoneEmptyFilterMap(t *testing.T) { f := func(s []int) bool { - filtered := FilterMap(s, Const[Option[int], int](None[int]())) + filtered := FilterMap(s, Const[int](None[int]())) return len(filtered) == 0 }