diff --git a/v2/context/readerioresult/bind.go b/v2/context/readerioresult/bind.go index 402e037..669e55c 100644 --- a/v2/context/readerioresult/bind.go +++ b/v2/context/readerioresult/bind.go @@ -96,7 +96,7 @@ func Bind[S1, S2, T any]( setter func(T) func(S1) S2, f Kleisli[S1, T], ) Operator[S1, S2] { - return RIOR.Bind[context.Context](setter, f) + return RIOR.Bind(setter, f) } // Let attaches the result of a computation to a context [S1] to produce a context [S2] @@ -256,7 +256,7 @@ func BindL[S, T any]( lens L.Lens[S, T], f Kleisli[T, T], ) Operator[S, S] { - return RIOR.BindL[context.Context](lens, f) + return RIOR.BindL(lens, f) } // LetL is a variant of Let that uses a lens to focus on a specific part of the context. @@ -570,7 +570,7 @@ func ApReaderS[S1, S2, T any]( setter func(T) func(S1) S2, fa Reader[context.Context, T], ) Operator[S1, S2] { - return ApS(setter, FromReader[T](fa)) + return ApS(setter, FromReader(fa)) } // ApReaderIOS is an applicative variant that works with ReaderIO values. @@ -585,7 +585,7 @@ func ApReaderIOS[S1, S2, T any]( setter func(T) func(S1) S2, fa ReaderIO[T], ) Operator[S1, S2] { - return ApS(setter, FromReaderIO[T](fa)) + return ApS(setter, FromReaderIO(fa)) } // ApEitherS is an applicative variant that works with Either (Result) values. @@ -600,7 +600,7 @@ func ApEitherS[S1, S2, T any]( setter func(T) func(S1) S2, fa Result[T], ) Operator[S1, S2] { - return ApS(setter, FromEither[T](fa)) + return ApS(setter, FromEither(fa)) } // ApResultS is an applicative variant that works with Result values. @@ -615,7 +615,7 @@ func ApResultS[S1, S2, T any]( setter func(T) func(S1) S2, fa Result[T], ) Operator[S1, S2] { - return ApS(setter, FromResult[T](fa)) + return ApS(setter, FromResult(fa)) } // ApIOEitherSL is a lens-based variant of ApIOEitherS. @@ -675,7 +675,7 @@ func ApReaderSL[S, T any]( lens L.Lens[S, T], fa Reader[context.Context, T], ) Operator[S, S] { - return ApSL(lens, FromReader[T](fa)) + return ApSL(lens, FromReader(fa)) } // ApReaderIOSL is a lens-based variant of ApReaderIOS. @@ -690,7 +690,7 @@ func ApReaderIOSL[S, T any]( lens L.Lens[S, T], fa ReaderIO[T], ) Operator[S, S] { - return ApSL(lens, FromReaderIO[T](fa)) + return ApSL(lens, FromReaderIO(fa)) } // ApEitherSL is a lens-based variant of ApEitherS. @@ -705,7 +705,7 @@ func ApEitherSL[S, T any]( lens L.Lens[S, T], fa Result[T], ) Operator[S, S] { - return ApSL(lens, FromEither[T](fa)) + return ApSL(lens, FromEither(fa)) } // ApResultSL is a lens-based variant of ApResultS. @@ -720,5 +720,5 @@ func ApResultSL[S, T any]( lens L.Lens[S, T], fa Result[T], ) Operator[S, S] { - return ApSL(lens, FromResult[T](fa)) + return ApSL(lens, FromResult(fa)) } diff --git a/v2/context/readerioresult/monoid.go b/v2/context/readerioresult/monoid.go index d0097b0..cc8905c 100644 --- a/v2/context/readerioresult/monoid.go +++ b/v2/context/readerioresult/monoid.go @@ -83,5 +83,5 @@ func AlternativeMonoid[A any](m monoid.Monoid[A]) Monoid[A] { // // Returns a Monoid for ReaderIOResult[A] with Alt-based combination. func AltMonoid[A any](zero Lazy[ReaderIOResult[A]]) Monoid[A] { - return RIOR.AltMonoid[context.Context](zero) + return RIOR.AltMonoid(zero) } diff --git a/v2/context/readerioresult/reader.go b/v2/context/readerioresult/reader.go index b2dfa85..aa8bf19 100644 --- a/v2/context/readerioresult/reader.go +++ b/v2/context/readerioresult/reader.go @@ -78,7 +78,7 @@ func Left[A any](l error) ReaderIOResult[A] { // //go:inline func Right[A any](r A) ReaderIOResult[A] { - return RIOR.Right[context.Context, A](r) + return RIOR.Right[context.Context](r) } // MonadMap transforms the success value of a [ReaderIOResult] using the provided function. @@ -458,12 +458,12 @@ func FromIO[A any](t IO[A]) ReaderIOResult[A] { //go:inline func FromReader[A any](t Reader[context.Context, A]) ReaderIOResult[A] { - return RIOR.FromReader[context.Context](t) + return RIOR.FromReader(t) } //go:inline func FromReaderIO[A any](t ReaderIO[A]) ReaderIOResult[A] { - return RIOR.FromReaderIO[context.Context](t) + return RIOR.FromReaderIO(t) } // FromLazy converts a [Lazy] computation into a [ReaderIOResult]. diff --git a/v2/context/readerioresult/reader_bench_test.go b/v2/context/readerioresult/reader_bench_test.go index 89fe17c..55fade4 100644 --- a/v2/context/readerioresult/reader_bench_test.go +++ b/v2/context/readerioresult/reader_bench_test.go @@ -561,7 +561,7 @@ func BenchmarkPipeline_Chain_Right(b *testing.B) { for i := 0; i < b.N; i++ { benchRIOE = F.Pipe1( rioe, - Chain(func(x int) ReaderIOResult[int] { return Right[int](x * 2) }), + Chain(func(x int) ReaderIOResult[int] { return Right(x * 2) }), ) } } @@ -573,7 +573,7 @@ func BenchmarkPipeline_Chain_Left(b *testing.B) { for i := 0; i < b.N; i++ { benchRIOE = F.Pipe1( rioe, - Chain(func(x int) ReaderIOResult[int] { return Right[int](x * 2) }), + Chain(func(x int) ReaderIOResult[int] { return Right(x * 2) }), ) } } @@ -586,7 +586,7 @@ func BenchmarkPipeline_Complex_Right(b *testing.B) { benchRIOE = F.Pipe3( rioe, Map(func(x int) int { return x * 2 }), - Chain(func(x int) ReaderIOResult[int] { return Right[int](x + 1) }), + Chain(func(x int) ReaderIOResult[int] { return Right(x + 1) }), Map(func(x int) int { return x * 2 }), ) } @@ -600,7 +600,7 @@ func BenchmarkPipeline_Complex_Left(b *testing.B) { benchRIOE = F.Pipe3( rioe, Map(func(x int) int { return x * 2 }), - Chain(func(x int) ReaderIOResult[int] { return Right[int](x + 1) }), + Chain(func(x int) ReaderIOResult[int] { return Right(x + 1) }), Map(func(x int) int { return x * 2 }), ) } @@ -610,7 +610,7 @@ func BenchmarkExecutePipeline_Complex_Right(b *testing.B) { rioe := F.Pipe3( Right(10), Map(func(x int) int { return x * 2 }), - Chain(func(x int) ReaderIOResult[int] { return Right[int](x + 1) }), + Chain(func(x int) ReaderIOResult[int] { return Right(x + 1) }), Map(func(x int) int { return x * 2 }), ) b.ResetTimer() diff --git a/v2/context/readerioresult/traverse.go b/v2/context/readerioresult/traverse.go index 3037fd6..1e0a93c 100644 --- a/v2/context/readerioresult/traverse.go +++ b/v2/context/readerioresult/traverse.go @@ -118,7 +118,7 @@ func SequenceRecord[K comparable, A any](ma map[K]ReaderIOResult[A]) ReaderIORes // // Returns a ReaderIOResult containing an array of transformed values. func MonadTraverseArraySeq[A, B any](as []A, f Kleisli[A, B]) ReaderIOResult[[]B] { - return array.MonadTraverse[[]A]( + return array.MonadTraverse( Of[[]B], Map[[]B, func(B) []B], ApSeq[[]B, B], @@ -168,7 +168,7 @@ func SequenceArraySeq[A any](ma []ReaderIOResult[A]) ReaderIOResult[[]A] { // MonadTraverseRecordSeq uses transforms a record [map[K]A] into [map[K]ReaderIOResult[B]] and then resolves that into a [ReaderIOResult[map[K]B]] func MonadTraverseRecordSeq[K comparable, A, B any](as map[K]A, f Kleisli[A, B]) ReaderIOResult[map[K]B] { - return record.MonadTraverse[map[K]A]( + return record.MonadTraverse( Of[map[K]B], Map[map[K]B, func(B) map[K]B], ApSeq[map[K]B, B], @@ -213,7 +213,7 @@ func SequenceRecordSeq[K comparable, A any](ma map[K]ReaderIOResult[A]) ReaderIO // // Returns a ReaderIOResult containing an array of transformed values. func MonadTraverseArrayPar[A, B any](as []A, f Kleisli[A, B]) ReaderIOResult[[]B] { - return array.MonadTraverse[[]A]( + return array.MonadTraverse( Of[[]B], Map[[]B, func(B) []B], ApPar[[]B, B], @@ -285,7 +285,7 @@ func TraverseRecordWithIndexPar[K comparable, A, B any](f func(K, A) ReaderIORes // MonadTraverseRecordPar uses transforms a record [map[K]A] into [map[K]ReaderIOResult[B]] and then resolves that into a [ReaderIOResult[map[K]B]] func MonadTraverseRecordPar[K comparable, A, B any](as map[K]A, f Kleisli[A, B]) ReaderIOResult[map[K]B] { - return record.MonadTraverse[map[K]A]( + return record.MonadTraverse( Of[map[K]B], Map[map[K]B, func(B) map[K]B], ApPar[map[K]B, B], diff --git a/v2/di/gen.go b/v2/di/gen.go index 789bfe6..08b531a 100644 --- a/v2/di/gen.go +++ b/v2/di/gen.go @@ -4,13 +4,12 @@ package di - import ( + A "github.com/IBM/fp-go/v2/array" + DIE "github.com/IBM/fp-go/v2/di/erasure" E "github.com/IBM/fp-go/v2/either" IOE "github.com/IBM/fp-go/v2/ioeither" T "github.com/IBM/fp-go/v2/tuple" - A "github.com/IBM/fp-go/v2/array" - DIE "github.com/IBM/fp-go/v2/di/erasure" ) // eraseProviderFactory1 creates a function that takes a variadic number of untyped arguments and from a function of 1 strongly typed arguments and 1 dependencies diff --git a/v2/di/provider.go b/v2/di/provider.go index 96361e1..41b92ac 100644 --- a/v2/di/provider.go +++ b/v2/di/provider.go @@ -75,5 +75,5 @@ func MakeProvider0[R any]( // ConstProvider simple implementation for a provider with a constant value func ConstProvider[R any](token InjectionToken[R], value R) DIE.Provider { - return MakeProvider0[R](token, IOE.Of[error](value)) + return MakeProvider0(token, IOE.Of[error](value)) } diff --git a/v2/di/token.go b/v2/di/token.go index 28024ba..d9a75ad 100644 --- a/v2/di/token.go +++ b/v2/di/token.go @@ -160,9 +160,9 @@ func makeInjectionToken[T any](name string, providerFactory O.Option[DIE.Provide toIdentity := toType[T]() return &injectionToken[T]{ token[T]{makeTokenBase(name, id, DIE.Identity, providerFactory), toIdentity}, - makeToken[O.Option[T]](fmt.Sprintf("Option[%s]", name), id, DIE.Option, toOptionType(toIdentity), providerFactory), - makeToken[IOE.IOEither[error, T]](fmt.Sprintf("IOEither[%s]", name), id, DIE.IOEither, toIOEitherType(toIdentity), providerFactory), - makeToken[IOO.IOOption[T]](fmt.Sprintf("IOOption[%s]", name), id, DIE.IOOption, toIOOptionType(toIdentity), providerFactory), + makeToken(fmt.Sprintf("Option[%s]", name), id, DIE.Option, toOptionType(toIdentity), providerFactory), + makeToken(fmt.Sprintf("IOEither[%s]", name), id, DIE.IOEither, toIOEitherType(toIdentity), providerFactory), + makeToken(fmt.Sprintf("IOOption[%s]", name), id, DIE.IOOption, toIOOptionType(toIdentity), providerFactory), } } @@ -188,16 +188,16 @@ func MakeMultiToken[T any](name string) MultiInjectionToken[T] { // container container := &injectionToken[[]T]{ token[[]T]{makeTokenBase(containerName, id, DIE.Multi|DIE.Identity, providerFactory), toContainer}, - makeToken[O.Option[[]T]](fmt.Sprintf("Option[%s]", containerName), id, DIE.Multi|DIE.Option, toOptionType(toContainer), providerFactory), - makeToken[IOE.IOEither[error, []T]](fmt.Sprintf("IOEither[%s]", containerName), id, DIE.Multi|DIE.IOEither, toIOEitherType(toContainer), providerFactory), - makeToken[IOO.IOOption[[]T]](fmt.Sprintf("IOOption[%s]", containerName), id, DIE.Multi|DIE.IOOption, toIOOptionType(toContainer), providerFactory), + makeToken(fmt.Sprintf("Option[%s]", containerName), id, DIE.Multi|DIE.Option, toOptionType(toContainer), providerFactory), + makeToken(fmt.Sprintf("IOEither[%s]", containerName), id, DIE.Multi|DIE.IOEither, toIOEitherType(toContainer), providerFactory), + makeToken(fmt.Sprintf("IOOption[%s]", containerName), id, DIE.Multi|DIE.IOOption, toIOOptionType(toContainer), providerFactory), } // item item := &injectionToken[T]{ token[T]{makeTokenBase(itemName, id, DIE.Item|DIE.Identity, providerFactory), toItem}, - makeToken[O.Option[T]](fmt.Sprintf("Option[%s]", itemName), id, DIE.Item|DIE.Option, toOptionType(toItem), providerFactory), - makeToken[IOE.IOEither[error, T]](fmt.Sprintf("IOEither[%s]", itemName), id, DIE.Item|DIE.IOEither, toIOEitherType(toItem), providerFactory), - makeToken[IOO.IOOption[T]](fmt.Sprintf("IOOption[%s]", itemName), id, DIE.Item|DIE.IOOption, toIOOptionType(toItem), providerFactory), + makeToken(fmt.Sprintf("Option[%s]", itemName), id, DIE.Item|DIE.Option, toOptionType(toItem), providerFactory), + makeToken(fmt.Sprintf("IOEither[%s]", itemName), id, DIE.Item|DIE.IOEither, toIOEitherType(toItem), providerFactory), + makeToken(fmt.Sprintf("IOOption[%s]", itemName), id, DIE.Item|DIE.IOOption, toIOOptionType(toItem), providerFactory), } // returns the token return &multiInjectionToken[T]{container, item} diff --git a/v2/either/bind.go b/v2/either/bind.go index 88f09d2..592d91b 100644 --- a/v2/either/bind.go +++ b/v2/either/bind.go @@ -273,7 +273,7 @@ func BindL[E, S, T any]( lens Lens[S, T], f Kleisli[E, T, T], ) Endomorphism[Either[E, S]] { - return Bind[E, S, S, T](lens.Set, function.Flow2(lens.Get, f)) + return Bind(lens.Set, function.Flow2(lens.Get, f)) } // LetL attaches the result of a pure computation to a context using a lens-based setter. @@ -323,7 +323,7 @@ func LetL[E, S, T any]( lens Lens[S, T], f Endomorphism[T], ) Endomorphism[Either[E, S]] { - return Let[E, S, S, T](lens.Set, function.Flow2(lens.Get, f)) + return Let[E](lens.Set, function.Flow2(lens.Get, f)) } // LetToL attaches a constant value to a context using a lens-based setter. @@ -371,5 +371,5 @@ func LetToL[E, S, T any]( lens Lens[S, T], b T, ) Endomorphism[Either[E, S]] { - return LetTo[E, S, S, T](lens.Set, b) + return LetTo[E](lens.Set, b) } diff --git a/v2/either/either.go b/v2/either/either.go index e09479a..b3097b2 100644 --- a/v2/either/either.go +++ b/v2/either/either.go @@ -362,7 +362,7 @@ func Fold[E, A, B any](onLeft func(E) B, onRight func(A) B) func(Either[E, A]) B // //go:inline func UnwrapError[A any](ma Either[error, A]) (A, error) { - return Unwrap[error](ma) + return Unwrap(ma) } // FromPredicate creates an Either based on a predicate. @@ -381,7 +381,7 @@ func FromPredicate[E, A any](pred func(A) bool, onFalse func(A) E) func(A) Eithe if pred(a) { return Right[E](a) } - return Left[A, E](onFalse(a)) + return Left[A](onFalse(a)) } } diff --git a/v2/either/either_bench_test.go b/v2/either/either_bench_test.go index 3ecc761..dc16850 100644 --- a/v2/either/either_bench_test.go +++ b/v2/either/either_bench_test.go @@ -267,7 +267,7 @@ func BenchmarkMonadChain_Left(b *testing.B) { func BenchmarkChain_Right(b *testing.B) { right := Right[error](42) - chainer := Chain[error](func(a int) Either[error, int] { return Right[error](a * 2) }) + chainer := Chain(func(a int) Either[error, int] { return Right[error](a * 2) }) b.ResetTimer() b.ReportAllocs() for i := 0; i < b.N; i++ { @@ -277,7 +277,7 @@ func BenchmarkChain_Right(b *testing.B) { func BenchmarkChain_Left(b *testing.B) { left := Left[int](errBench) - chainer := Chain[error](func(a int) Either[error, int] { return Right[error](a * 2) }) + chainer := Chain(func(a int) Either[error, int] { return Right[error](a * 2) }) b.ResetTimer() b.ReportAllocs() for i := 0; i < b.N; i++ { @@ -297,7 +297,7 @@ func BenchmarkChainFirst_Right(b *testing.B) { func BenchmarkChainFirst_Left(b *testing.B) { left := Left[int](errBench) - chainer := ChainFirst[error](func(a int) Either[error, string] { return Right[error]("logged") }) + chainer := ChainFirst(func(a int) Either[error, string] { return Right[error]("logged") }) b.ResetTimer() b.ReportAllocs() for i := 0; i < b.N; i++ { @@ -357,7 +357,7 @@ func BenchmarkMonadAp_LeftRight(b *testing.B) { func BenchmarkAp_RightRight(b *testing.B) { fab := Right[error](func(a int) int { return a * 2 }) fa := Right[error](42) - ap := Ap[int, error, int](fa) + ap := Ap[int](fa) b.ResetTimer() b.ReportAllocs() for i := 0; i < b.N; i++ { @@ -378,7 +378,7 @@ func BenchmarkAlt_RightRight(b *testing.B) { func BenchmarkAlt_LeftRight(b *testing.B) { left := Left[int](errBench) - alternative := Alt[error](func() Either[error, int] { return Right[error](99) }) + alternative := Alt(func() Either[error, int] { return Right[error](99) }) b.ResetTimer() b.ReportAllocs() for i := 0; i < b.N; i++ { @@ -388,7 +388,7 @@ func BenchmarkAlt_LeftRight(b *testing.B) { func BenchmarkOrElse_Right(b *testing.B) { right := Right[error](42) - recover := OrElse[error](func(e error) Either[error, int] { return Right[error](0) }) + recover := OrElse(func(e error) Either[error, int] { return Right[error](0) }) b.ResetTimer() b.ReportAllocs() for i := 0; i < b.N; i++ { @@ -457,7 +457,7 @@ func BenchmarkSwap_Left(b *testing.B) { func BenchmarkGetOrElse_Right(b *testing.B) { right := Right[error](42) - getter := GetOrElse[error](func(e error) int { return 0 }) + getter := GetOrElse(func(e error) int { return 0 }) b.ResetTimer() b.ReportAllocs() for i := 0; i < b.N; i++ { @@ -467,7 +467,7 @@ func BenchmarkGetOrElse_Right(b *testing.B) { func BenchmarkGetOrElse_Left(b *testing.B) { left := Left[int](errBench) - getter := GetOrElse[error](func(e error) int { return 0 }) + getter := GetOrElse(func(e error) int { return 0 }) b.ResetTimer() b.ReportAllocs() for i := 0; i < b.N; i++ { @@ -507,7 +507,7 @@ func BenchmarkPipeline_Chain_Right(b *testing.B) { for i := 0; i < b.N; i++ { benchResult = F.Pipe1( right, - Chain[error](func(x int) Either[error, int] { return Right[error](x * 2) }), + Chain(func(x int) Either[error, int] { return Right[error](x * 2) }), ) } } @@ -519,7 +519,7 @@ func BenchmarkPipeline_Chain_Left(b *testing.B) { for i := 0; i < b.N; i++ { benchResult = F.Pipe1( left, - Chain[error](func(x int) Either[error, int] { return Right[error](x * 2) }), + Chain(func(x int) Either[error, int] { return Right[error](x * 2) }), ) } } @@ -532,7 +532,7 @@ func BenchmarkPipeline_Complex_Right(b *testing.B) { benchResult = F.Pipe3( right, Map[error](func(x int) int { return x * 2 }), - Chain[error](func(x int) Either[error, int] { return Right[error](x + 1) }), + Chain(func(x int) Either[error, int] { return Right[error](x + 1) }), Map[error](func(x int) int { return x * 2 }), ) } @@ -546,7 +546,7 @@ func BenchmarkPipeline_Complex_Left(b *testing.B) { benchResult = F.Pipe3( left, Map[error](func(x int) int { return x * 2 }), - Chain[error](func(x int) Either[error, int] { return Right[error](x + 1) }), + Chain(func(x int) Either[error, int] { return Right[error](x + 1) }), Map[error](func(x int) int { return x * 2 }), ) } @@ -599,7 +599,7 @@ func BenchmarkDo(b *testing.B) { func BenchmarkBind_Right(b *testing.B) { type State struct{ value int } initial := Do[error](State{}) - binder := Bind[error, State, State]( + binder := Bind( func(v int) func(State) State { return func(s State) State { return State{value: v} } }, @@ -617,7 +617,7 @@ func BenchmarkBind_Right(b *testing.B) { func BenchmarkLet_Right(b *testing.B) { type State struct{ value int } initial := Right[error](State{value: 10}) - letter := Let[error, State, State]( + letter := Let[error]( func(v int) func(State) State { return func(s State) State { return State{value: s.value + v} } }, diff --git a/v2/either/either_coverage_test.go b/v2/either/either_coverage_test.go index 0dd6300..9869bba 100644 --- a/v2/either/either_coverage_test.go +++ b/v2/either/either_coverage_test.go @@ -341,7 +341,7 @@ func TestTraverseRecordWithIndex(t *testing.T) { } input := map[string]string{"a": "1"} - result := TraverseRecordWithIndex[string](validate)(input) + result := TraverseRecordWithIndex(validate)(input) expected := Right[error](map[string]string{"a": "a:1"}) assert.Equal(t, expected, result) } @@ -658,7 +658,7 @@ func TestAlternativeMonoid(t *testing.T) { // Test AltMonoid func TestAltMonoid(t *testing.T) { zero := func() Either[error, int] { return Left[int](errors.New("empty")) } - m := AltMonoid[error, int](zero) + m := AltMonoid(zero) result := m.Concat(Left[int](errors.New("err1")), Right[error](42)) assert.Equal(t, Right[error](42), result) diff --git a/v2/either/either_test.go b/v2/either/either_test.go index 09271e6..f7fdcaf 100644 --- a/v2/either/either_test.go +++ b/v2/either/either_test.go @@ -47,7 +47,7 @@ func TestMapEither(t *testing.T) { assert.Equal(t, F.Pipe1(Right[error]("abc"), Map[error](utils.StringLen)), Right[error](3)) - val2 := F.Pipe1(Left[string, string]("s"), Map[string](utils.StringLen)) + val2 := F.Pipe1(Left[string]("s"), Map[string](utils.StringLen)) exp2 := Left[int]("s") assert.Equal(t, val2, exp2) @@ -69,15 +69,15 @@ func TestReduce(t *testing.T) { s := S.Semigroup() assert.Equal(t, "foobar", F.Pipe1(Right[string]("bar"), Reduce[string](s.Concat, "foo"))) - assert.Equal(t, "foo", F.Pipe1(Left[string, string]("bar"), Reduce[string](s.Concat, "foo"))) + assert.Equal(t, "foo", F.Pipe1(Left[string]("bar"), Reduce[string](s.Concat, "foo"))) } func TestAp(t *testing.T) { f := S.Size - assert.Equal(t, Right[string](3), F.Pipe1(Right[string](f), Ap[int, string, string](Right[string]("abc")))) - assert.Equal(t, Left[int]("maError"), F.Pipe1(Right[string](f), Ap[int, string, string](Left[string, string]("maError")))) - assert.Equal(t, Left[int]("mabError"), F.Pipe1(Left[func(string) int]("mabError"), Ap[int, string, string](Left[string, string]("maError")))) + assert.Equal(t, Right[string](3), F.Pipe1(Right[string](f), Ap[int](Right[string]("abc")))) + assert.Equal(t, Left[int]("maError"), F.Pipe1(Right[string](f), Ap[int](Left[string, string]("maError")))) + assert.Equal(t, Left[int]("mabError"), F.Pipe1(Left[func(string) int]("mabError"), Ap[int](Left[string, string]("maError")))) } func TestAlt(t *testing.T) { @@ -91,7 +91,7 @@ func TestChainFirst(t *testing.T) { f := F.Flow2(S.Size, Right[string, int]) assert.Equal(t, Right[string]("abc"), F.Pipe1(Right[string]("abc"), ChainFirst(f))) - assert.Equal(t, Left[string, string]("maError"), F.Pipe1(Left[string, string]("maError"), ChainFirst(f))) + assert.Equal(t, Left[string]("maError"), F.Pipe1(Left[string]("maError"), ChainFirst(f))) } func TestChainOptionK(t *testing.T) { diff --git a/v2/either/functor.go b/v2/either/functor.go index f2b0a89..73f34c0 100644 --- a/v2/either/functor.go +++ b/v2/either/functor.go @@ -22,7 +22,7 @@ import ( type eitherFunctor[E, A, B any] struct{} func (o *eitherFunctor[E, A, B]) Map(f func(A) B) Operator[E, A, B] { - return Map[E, A, B](f) + return Map[E](f) } // Functor implements the functoric operations for Either. diff --git a/v2/either/logger.go b/v2/either/logger.go index 8f3305c..0b55dbc 100644 --- a/v2/either/logger.go +++ b/v2/either/logger.go @@ -26,7 +26,7 @@ func _log[E, A any](left func(string, ...any), right func(string, ...any), prefi return Fold( func(e E) Either[E, A] { left("%s: %v", prefix, e) - return Left[A, E](e) + return Left[A](e) }, func(a A) Either[E, A] { right("%s: %v", prefix, a) diff --git a/v2/either/monad.go b/v2/either/monad.go index 93f5ed6..fe97347 100644 --- a/v2/either/monad.go +++ b/v2/either/monad.go @@ -22,19 +22,19 @@ import ( type eitherMonad[E, A, B any] struct{} func (o *eitherMonad[E, A, B]) Of(a A) Either[E, A] { - return Of[E, A](a) + return Of[E](a) } func (o *eitherMonad[E, A, B]) Map(f func(A) B) Operator[E, A, B] { - return Map[E, A, B](f) + return Map[E](f) } func (o *eitherMonad[E, A, B]) Chain(f func(A) Either[E, B]) Operator[E, A, B] { - return Chain[E, A, B](f) + return Chain(f) } func (o *eitherMonad[E, A, B]) Ap(fa Either[E, A]) Operator[E, func(A) B, B] { - return Ap[B, E, A](fa) + return Ap[B](fa) } // Monad implements the monadic operations for Either. diff --git a/v2/either/pointed.go b/v2/either/pointed.go index c6b9d89..1f50454 100644 --- a/v2/either/pointed.go +++ b/v2/either/pointed.go @@ -22,7 +22,7 @@ import ( type eitherPointed[E, A any] struct{} func (o *eitherPointed[E, A]) Of(a A) Either[E, A] { - return Of[E, A](a) + return Of[E](a) } // Pointed implements the pointed functor operations for Either. diff --git a/v2/function/function_test.go b/v2/function/function_test.go index 74fdf38..9bf86b4 100644 --- a/v2/function/function_test.go +++ b/v2/function/function_test.go @@ -71,14 +71,14 @@ func TestConstant(t *testing.T) { // TestConstant1 tests the Constant1 function func TestConstant1(t *testing.T) { t.Run("ignores input and returns constant", func(t *testing.T) { - alwaysZero := Constant1[string, int](0) + alwaysZero := Constant1[string](0) assert.Equal(t, 0, alwaysZero("anything")) assert.Equal(t, 0, alwaysZero("something else")) assert.Equal(t, 0, alwaysZero("")) }) t.Run("works with different types", func(t *testing.T) { - defaultName := Constant1[int, string]("Unknown") + defaultName := Constant1[int]("Unknown") assert.Equal(t, "Unknown", defaultName(42)) assert.Equal(t, "Unknown", defaultName(0)) }) @@ -87,13 +87,13 @@ func TestConstant1(t *testing.T) { // TestConstant2 tests the Constant2 function func TestConstant2(t *testing.T) { t.Run("ignores both inputs and returns constant", func(t *testing.T) { - alwaysTrue := Constant2[int, string, bool](true) + alwaysTrue := Constant2[int, string](true) assert.True(t, alwaysTrue(42, "test")) assert.True(t, alwaysTrue(0, "")) }) t.Run("works with different types", func(t *testing.T) { - alwaysPi := Constant2[string, bool, float64](3.14) + alwaysPi := Constant2[string, bool](3.14) assert.Equal(t, 3.14, alwaysPi("test", true)) }) } @@ -296,8 +296,8 @@ func TestTernary(t *testing.T) { isPositive := func(n int) bool { return n > 0 } classify := Ternary( isPositive, - Constant1[int, string]("positive"), - Constant1[int, string]("non-positive"), + Constant1[int]("positive"), + Constant1[int]("non-positive"), ) assert.Equal(t, "positive", classify(5)) diff --git a/v2/function/generic/cache.go b/v2/function/generic/cache.go index 5c12041..813efcf 100644 --- a/v2/function/generic/cache.go +++ b/v2/function/generic/cache.go @@ -28,7 +28,7 @@ func Memoize[F ~func(K) T, K comparable, T any](f F) F { // ContramapMemoize converts a unary function into a unary function that caches the value depending on the parameter func ContramapMemoize[F ~func(A) T, KF func(A) K, A any, K comparable, T any](kf KF) func(F) F { - return CacheCallback[func(F) F, func() func() T](kf, getOrCreate[K, T]()) + return CacheCallback[func(F) F](kf, getOrCreate[K, T]()) } // getOrCreate is a naive implementation of a cache, without bounds diff --git a/v2/http/builder/builder.go b/v2/http/builder/builder.go index 47c3b9f..f68991e 100644 --- a/v2/http/builder/builder.go +++ b/v2/http/builder/builder.go @@ -377,7 +377,7 @@ func WithoutHeader(name string) Endomorphism { // // Deprecated: use [WithJSON] instead func WithJson[T any](data T) Endomorphism { - return WithJSON[T](data) + return WithJSON(data) } // WithJSON creates a [Endomorphism] to send JSON payload diff --git a/v2/http/form/form_test.go b/v2/http/form/form_test.go index 8d3d5ce..1654898 100644 --- a/v2/http/form/form_test.go +++ b/v2/http/form/form_test.go @@ -36,7 +36,7 @@ var ( func TestLaws(t *testing.T) { name := "Content-Type" - fieldLaws := LT.AssertLaws[url.Values, O.Option[string]](t, O.Eq(sEq), valuesEq)(AtValue(name)) + fieldLaws := LT.AssertLaws(t, O.Eq(sEq), valuesEq)(AtValue(name)) n := O.None[string]() s1 := O.Some("s1") diff --git a/v2/http/headers/headers_test.go b/v2/http/headers/headers_test.go index a0e04f7..e90362c 100644 --- a/v2/http/headers/headers_test.go +++ b/v2/http/headers/headers_test.go @@ -36,7 +36,7 @@ var ( func TestLaws(t *testing.T) { name := "Content-Type" - fieldLaws := LT.AssertLaws[http.Header, O.Option[string]](t, O.Eq(sEq), valuesEq)(AtValue(name)) + fieldLaws := LT.AssertLaws(t, O.Eq(sEq), valuesEq)(AtValue(name)) n := O.None[string]() s1 := O.Some("s1") diff --git a/v2/identity/identity_test.go b/v2/identity/identity_test.go index 857dedc..e6d745b 100644 --- a/v2/identity/identity_test.go +++ b/v2/identity/identity_test.go @@ -83,12 +83,12 @@ func TestMonadMap(t *testing.T) { func TestMapTo(t *testing.T) { t.Run("replaces with constant int", func(t *testing.T) { - result := F.Pipe1("ignored", MapTo[string, int](100)) + result := F.Pipe1("ignored", MapTo[string](100)) assert.Equal(t, 100, result) }) t.Run("replaces with constant string", func(t *testing.T) { - result := F.Pipe1(42, MapTo[int, string]("constant")) + result := F.Pipe1(42, MapTo[int]("constant")) assert.Equal(t, "constant", result) }) } @@ -165,7 +165,7 @@ func TestMonadChainFirst(t *testing.T) { func TestAp(t *testing.T) { t.Run("applies function", func(t *testing.T) { - result := F.Pipe1(utils.Double, Ap[int, int](1)) + result := F.Pipe1(utils.Double, Ap[int](1)) assert.Equal(t, 2, result) }) @@ -173,7 +173,7 @@ func TestAp(t *testing.T) { add := func(a int) func(int) int { return func(b int) int { return a + b } } - result := F.Pipe1(add(10), Ap[int, int](5)) + result := F.Pipe1(add(10), Ap[int](5)) assert.Equal(t, 15, result) }) @@ -181,7 +181,7 @@ func TestAp(t *testing.T) { toString := func(n int) string { return fmt.Sprintf("Number: %d", n) } - result := F.Pipe1(toString, Ap[string, int](42)) + result := F.Pipe1(toString, Ap[string](42)) assert.Equal(t, "Number: 42", result) }) } @@ -196,7 +196,7 @@ func TestMonadAp(t *testing.T) { func TestFlap(t *testing.T) { t.Run("flips application", func(t *testing.T) { double := func(n int) int { return n * 2 } - result := F.Pipe1(double, Flap[int, int](5)) + result := F.Pipe1(double, Flap[int](5)) assert.Equal(t, 10, result) }) @@ -209,7 +209,7 @@ func TestFlap(t *testing.T) { results := make([]int, len(funcs)) for i, f := range funcs { - results[i] = Flap[int, int](5)(f) + results[i] = Flap[int](5)(f) } assert.Equal(t, []int{10, 15, 25}, results) diff --git a/v2/internal/array/array.go b/v2/internal/array/array.go index 9841093..d68da66 100644 --- a/v2/internal/array/array.go +++ b/v2/internal/array/array.go @@ -28,7 +28,7 @@ func Slice[GA ~[]A, A any](low, high int) func(as GA) GA { } if low > length { - return Empty[GA, A]() + return Empty[GA]() } // End index > array length: slice to the end @@ -38,7 +38,7 @@ func Slice[GA ~[]A, A any](low, high int) func(as GA) GA { // Start >= end: return empty array if low >= high { - return Empty[GA, A]() + return Empty[GA]() } return as[low:high] @@ -56,7 +56,7 @@ func SliceRight[GA ~[]A, A any](start int) func(as GA) GA { // Start index > array length: return empty array if start > length { - return Empty[GA, A]() + return Empty[GA]() } return as[start:] diff --git a/v2/internal/functor/flap.go b/v2/internal/functor/flap.go index 3ec843e..ed0d93f 100644 --- a/v2/internal/functor/flap.go +++ b/v2/internal/functor/flap.go @@ -27,12 +27,12 @@ func MonadFlap[FAB ~func(A) B, A, B, HKTFAB, HKTB any]( fab HKTFAB, a A, ) HKTB { - return fmap(fab, flap[FAB, A, B](a)) + return fmap(fab, flap[FAB](a)) } func Flap[FAB ~func(A) B, A, B, HKTFAB, HKTB any]( fmap func(func(FAB) B) func(HKTFAB) HKTB, a A, ) func(HKTFAB) HKTB { - return fmap(flap[FAB, A, B](a)) + return fmap(flap[FAB](a)) } diff --git a/v2/io/bind.go b/v2/io/bind.go index 7cc129c..5548a74 100644 --- a/v2/io/bind.go +++ b/v2/io/bind.go @@ -217,7 +217,7 @@ func BindL[S, T any]( lens L.Lens[S, T], f Kleisli[T, T], ) Operator[S, S] { - return Bind[S, S, T](lens.Set, F.Flow2(lens.Get, f)) + return Bind(lens.Set, F.Flow2(lens.Get, f)) } // LetL attaches the result of a pure computation to a context using a lens-based setter. @@ -250,7 +250,7 @@ func LetL[S, T any]( lens L.Lens[S, T], f func(T) T, ) Operator[S, S] { - return Let[S, S, T](lens.Set, F.Flow2(lens.Get, f)) + return Let(lens.Set, F.Flow2(lens.Get, f)) } // LetToL attaches a constant value to a context using a lens-based setter. @@ -281,5 +281,5 @@ func LetToL[S, T any]( lens L.Lens[S, T], b T, ) Operator[S, S] { - return LetTo[S, S, T](lens.Set, b) + return LetTo(lens.Set, b) } diff --git a/v2/io/coverage_test.go b/v2/io/coverage_test.go index 653f8b7..3da448b 100644 --- a/v2/io/coverage_test.go +++ b/v2/io/coverage_test.go @@ -49,7 +49,7 @@ func TestMonadMapTo(t *testing.T) { // Test MapTo func TestMapTo(t *testing.T) { - result := F.Pipe1(Of(1), MapTo[int, string]("hello")) + result := F.Pipe1(Of(1), MapTo[int]("hello")) assert.Equal(t, "hello", result()) } @@ -276,7 +276,7 @@ func TestWithResource(t *testing.T) { }) } - withRes := WithResource[int, int, any](Of(onCreate()), onRelease) + withRes := WithResource[int, int](Of(onCreate()), onRelease) result := withRes(func(x int) IO[int] { return Of(x * 2) @@ -604,7 +604,7 @@ func TestSequenceSeqTuple2(t *testing.T) { io1 := func() int { order = append(order, 1); return 10 } io2 := func() int { order = append(order, 2); return 20 } - tup := T.MakeTuple2[IO[int], IO[int]](io1, io2) + tup := T.MakeTuple2(io1, io2) result := SequenceSeqTuple2(tup) tuple := result() @@ -804,7 +804,7 @@ func TestSequenceSeqTuple3(t *testing.T) { io2 := func() int { order = append(order, 2); return 20 } io3 := func() int { order = append(order, 3); return 30 } - tup := T.MakeTuple3[IO[int], IO[int], IO[int]](io1, io2, io3) + tup := T.MakeTuple3(io1, io2, io3) result := SequenceSeqTuple3(tup) tuple := result() @@ -862,7 +862,7 @@ func TestSequenceSeqTuple4(t *testing.T) { io3 := func() int { order = append(order, 3); return 3 } io4 := func() int { order = append(order, 4); return 4 } - tup := T.MakeTuple4[IO[int], IO[int], IO[int], IO[int]](io1, io2, io3, io4) + tup := T.MakeTuple4(io1, io2, io3, io4) result := SequenceSeqTuple4(tup) tuple := result() @@ -939,7 +939,7 @@ func TestSequenceSeqTuple1(t *testing.T) { var executed bool io1 := func() int { executed = true; return 42 } - tup := T.MakeTuple1[IO[int]](io1) + tup := T.MakeTuple1(io1) result := SequenceSeqTuple1(tup) tuple := result() @@ -1013,7 +1013,7 @@ func TestSequenceSeqTuple5(t *testing.T) { io4 := func() int { order = append(order, 4); return 4 } io5 := func() int { order = append(order, 5); return 5 } - tup := T.MakeTuple5[IO[int], IO[int], IO[int], IO[int], IO[int]](io1, io2, io3, io4, io5) + tup := T.MakeTuple5(io1, io2, io3, io4, io5) result := SequenceSeqTuple5(tup) tuple := result() @@ -1231,7 +1231,7 @@ func TestSequenceSeqTuple6(t *testing.T) { io5 := func() int { order = append(order, 5); return 5 } io6 := func() int { order = append(order, 6); return 6 } - tup := T.MakeTuple6[IO[int], IO[int], IO[int], IO[int], IO[int], IO[int]](io1, io2, io3, io4, io5, io6) + tup := T.MakeTuple6(io1, io2, io3, io4, io5, io6) result := SequenceSeqTuple6(tup) tuple := result() diff --git a/v2/io/generic/io.go b/v2/io/generic/io.go index 5cc8445..eac8de4 100644 --- a/v2/io/generic/io.go +++ b/v2/io/generic/io.go @@ -93,7 +93,7 @@ func MonadChainTo[GA ~func() A, GB ~func() B, A, B any](fa GA, fb GB) GB { // ChainTo composes computations in sequence, ignoring the return value of the first computation func ChainTo[GA ~func() A, GB ~func() B, A, B any](fb GB) func(GA) GB { - return Chain[GA, GB](F.Constant1[A](fb)) + return Chain[GA](F.Constant1[A](fb)) } // MonadChainFirst composes computations in sequence, using the return value of one computation to determine the next computation and @@ -130,7 +130,7 @@ func Flatten[GA ~func() A, GAA ~func() GA, A any](mma GAA) GA { // Memoize computes the value of the provided IO monad lazily but exactly once func Memoize[GA ~func() A, A any](ma GA) GA { - return L.Memoize[GA, A](ma) + return L.Memoize(ma) } // Delay creates an operation that passes in the value after some delay diff --git a/v2/ioeither/bind.go b/v2/ioeither/bind.go index f4b3b30..29a4107 100644 --- a/v2/ioeither/bind.go +++ b/v2/ioeither/bind.go @@ -233,7 +233,7 @@ func BindL[E, S, T any]( lens L.Lens[S, T], f Kleisli[E, T, T], ) Operator[E, S, S] { - return Bind[E, S, S, T](lens.Set, F.Flow2(lens.Get, f)) + return Bind(lens.Set, F.Flow2(lens.Get, f)) } // LetL attaches the result of a pure computation to a context using a lens-based setter. @@ -265,7 +265,7 @@ func LetL[E, S, T any]( lens L.Lens[S, T], f func(T) T, ) Operator[E, S, S] { - return Let[E, S, S, T](lens.Set, F.Flow2(lens.Get, f)) + return Let[E](lens.Set, F.Flow2(lens.Get, f)) } // LetToL attaches a constant value to a context using a lens-based setter. @@ -296,5 +296,5 @@ func LetToL[E, S, T any]( lens L.Lens[S, T], b T, ) Operator[E, S, S] { - return LetTo[E, S, S, T](lens.Set, b) + return LetTo[E](lens.Set, b) } diff --git a/v2/ioeither/generic/ioeither.go b/v2/ioeither/generic/ioeither.go index 7ccecf7..71f2e1b 100644 --- a/v2/ioeither/generic/ioeither.go +++ b/v2/ioeither/generic/ioeither.go @@ -125,7 +125,7 @@ func MonadChainTo[GA ~func() either.Either[E, A], GB ~func() either.Either[E, B] } func ChainTo[GA ~func() either.Either[E, A], GB ~func() either.Either[E, B], E, A, B any](fb GB) func(GA) GB { - return Chain[GA, GB, E, A, B](F.Constant1[A](fb)) + return Chain[GA](F.Constant1[A](fb)) } // Deprecated: @@ -394,7 +394,7 @@ func FromImpure[GA ~func() either.Either[E, any], IMP ~func(), E any](f IMP) GA // // Deprecated: func Defer[GEA ~func() either.Either[E, A], E, A any](gen func() GEA) GEA { - return IO.Defer[GEA](gen) + return IO.Defer(gen) } // Deprecated: diff --git a/v2/ioeither/http/request.go b/v2/ioeither/http/request.go index 94514a7..47f1a1f 100644 --- a/v2/ioeither/http/request.go +++ b/v2/ioeither/http/request.go @@ -140,6 +140,6 @@ func readJSON(client Client) func(Requester) ioeither.IOEither[error, []byte] { func ReadJSON[A any](client Client) func(Requester) ioeither.IOEither[error, A] { return F.Flow2( readJSON(client), - ioeither.ChainEitherK[error](J.Unmarshal[A]), + ioeither.ChainEitherK(J.Unmarshal[A]), ) } diff --git a/v2/ioeither/ioeither_test.go b/v2/ioeither/ioeither_test.go index ae1f813..f43c5b7 100644 --- a/v2/ioeither/ioeither_test.go +++ b/v2/ioeither/ioeither_test.go @@ -76,7 +76,7 @@ func TestChainIOK(t *testing.T) { }) assert.Equal(t, E.Right[string]("1"), f(Right[string](1))()) - assert.Equal(t, E.Left[string, string]("b"), f(Left[int]("b"))()) + assert.Equal(t, E.Left[string]("b"), f(Left[int]("b"))()) } func TestChainWithIO(t *testing.T) { @@ -102,7 +102,7 @@ func TestChainFirst(t *testing.T) { ch := ChainFirst(f) assert.Equal(t, E.Of[string]("foo"), F.Pipe1(good, ch)()) - assert.Equal(t, E.Left[string, string]("foo"), F.Pipe1(bad, ch)()) + assert.Equal(t, E.Left[string]("foo"), F.Pipe1(bad, ch)()) } func TestChainFirstIOK(t *testing.T) { diff --git a/v2/ioeither/monad.go b/v2/ioeither/monad.go index a47447e..a3ace04 100644 --- a/v2/ioeither/monad.go +++ b/v2/ioeither/monad.go @@ -30,27 +30,27 @@ type ( ) func (o *ioEitherPointed[E, A]) Of(a A) IOEither[E, A] { - return Of[E, A](a) + return Of[E](a) } func (o *ioEitherMonad[E, A, B]) Of(a A) IOEither[E, A] { - return Of[E, A](a) + return Of[E](a) } func (o *ioEitherMonad[E, A, B]) Map(f func(A) B) Operator[E, A, B] { - return Map[E, A, B](f) + return Map[E](f) } func (o *ioEitherMonad[E, A, B]) Chain(f Kleisli[E, A, B]) Operator[E, A, B] { - return Chain[E, A, B](f) + return Chain(f) } func (o *ioEitherMonad[E, A, B]) Ap(fa IOEither[E, A]) Operator[E, func(A) B, B] { - return Ap[B, E, A](fa) + return Ap[B](fa) } func (o *ioEitherFunctor[E, A, B]) Map(f func(A) B) Operator[E, A, B] { - return Map[E, A, B](f) + return Map[E](f) } // Pointed implements the pointed operations for [IOEither] diff --git a/v2/iooption/bind.go b/v2/iooption/bind.go index 5de26c9..5410ddb 100644 --- a/v2/iooption/bind.go +++ b/v2/iooption/bind.go @@ -225,7 +225,7 @@ func BindL[S, T any]( lens L.Lens[S, T], f Kleisli[T, T], ) Kleisli[IOOption[S], S] { - return Bind[S, S, T](lens.Set, F.Flow2(lens.Get, f)) + return Bind(lens.Set, F.Flow2(lens.Get, f)) } // LetL attaches the result of a pure computation to a context using a lens-based setter. @@ -258,7 +258,7 @@ func LetL[S, T any]( lens L.Lens[S, T], f func(T) T, ) Kleisli[IOOption[S], S] { - return Let[S, S, T](lens.Set, F.Flow2(lens.Get, f)) + return Let(lens.Set, F.Flow2(lens.Get, f)) } // LetToL attaches a constant value to a context using a lens-based setter. @@ -289,5 +289,5 @@ func LetToL[S, T any]( lens L.Lens[S, T], b T, ) Kleisli[IOOption[S], S] { - return LetTo[S, S, T](lens.Set, b) + return LetTo(lens.Set, b) } diff --git a/v2/iooption/generic/iooption.go b/v2/iooption/generic/iooption.go index e128cdd..477ec0c 100644 --- a/v2/iooption/generic/iooption.go +++ b/v2/iooption/generic/iooption.go @@ -238,7 +238,7 @@ func Fold[GA ~func() O.Option[A], GB ~func() B, A, B any](onNone func() GB, onSo // Defer creates an IO by creating a brand new IO via a generator function, each time func Defer[GA ~func() O.Option[A], A any](gen func() GA) GA { - return IO.Defer[GA](gen) + return IO.Defer(gen) } func MonadAlt[LAZY ~func() GIOA, GIOA ~func() O.Option[A], A any](first GIOA, second LAZY) GIOA { diff --git a/v2/iterator/stateless/bind.go b/v2/iterator/stateless/bind.go index 7b2bc06..b7b0e69 100644 --- a/v2/iterator/stateless/bind.go +++ b/v2/iterator/stateless/bind.go @@ -73,7 +73,7 @@ func Bind[S1, S2, T any]( setter func(T) func(S1) S2, f Kleisli[S1, T], ) Kleisli[Iterator[S1], S2] { - return G.Bind[Iterator[S1], Iterator[S2], Iterator[T], S1, S2, T](setter, f) + return G.Bind[Iterator[S1], Iterator[S2]](setter, f) } // Let attaches the result of a computation to a context [S1] to produce a context [S2] @@ -81,7 +81,7 @@ func Let[S1, S2, T any]( setter func(T) func(S1) S2, f func(S1) T, ) Kleisli[Iterator[S1], S2] { - return G.Let[Iterator[S1], Iterator[S2], S1, S2, T](setter, f) + return G.Let[Iterator[S1], Iterator[S2]](setter, f) } // LetTo attaches the a value to a context [S1] to produce a context [S2] @@ -89,14 +89,14 @@ func LetTo[S1, S2, T any]( setter func(T) func(S1) S2, b T, ) Kleisli[Iterator[S1], S2] { - return G.LetTo[Iterator[S1], Iterator[S2], S1, S2, T](setter, b) + return G.LetTo[Iterator[S1], Iterator[S2]](setter, b) } // BindTo initializes a new state [S1] from a value [T] func BindTo[S1, T any]( setter func(T) S1, ) Kleisli[Iterator[T], S1] { - return G.BindTo[Iterator[S1], Iterator[T], S1, T](setter) + return G.BindTo[Iterator[S1], Iterator[T]](setter) } // ApS attaches a value to a context [S1] to produce a context [S2] by considering @@ -136,5 +136,5 @@ func ApS[S1, S2, T any]( setter func(T) func(S1) S2, fa Iterator[T], ) Kleisli[Iterator[S1], S2] { - return G.ApS[Iterator[func(T) S2], Iterator[S1], Iterator[S2], Iterator[T], S1, S2, T](setter, fa) + return G.ApS[Iterator[func(T) S2], Iterator[S1], Iterator[S2]](setter, fa) } diff --git a/v2/iterator/stateless/cycle.go b/v2/iterator/stateless/cycle.go index ffcaa2b..ac7ca17 100644 --- a/v2/iterator/stateless/cycle.go +++ b/v2/iterator/stateless/cycle.go @@ -22,5 +22,5 @@ import ( // DropWhile creates an [Iterator] that drops elements from the [Iterator] as long as the predicate is true; afterwards, returns every element. // Note, the [Iterator] does not produce any output until the predicate first becomes false func Cycle[U any](ma Iterator[U]) Iterator[U] { - return G.Cycle[Iterator[U]](ma) + return G.Cycle(ma) } diff --git a/v2/iterator/stateless/first.go b/v2/iterator/stateless/first.go index 9d47ad9..5b4b389 100644 --- a/v2/iterator/stateless/first.go +++ b/v2/iterator/stateless/first.go @@ -22,5 +22,5 @@ import ( // First returns the first item in an iterator if such an item exists func First[U any](mu Iterator[U]) O.Option[U] { - return G.First[Iterator[U]](mu) + return G.First(mu) } diff --git a/v2/iterator/stateless/generic/iterator.go b/v2/iterator/stateless/generic/iterator.go index f7a2b4b..37029bf 100644 --- a/v2/iterator/stateless/generic/iterator.go +++ b/v2/iterator/stateless/generic/iterator.go @@ -247,7 +247,7 @@ func Ap[GUV ~func() O.Option[P.Pair[GUV, func(U) V]], GV ~func() O.Option[P.Pair } func MonadAp[GUV ~func() O.Option[P.Pair[GUV, func(U) V]], GV ~func() O.Option[P.Pair[GV, V]], GU ~func() O.Option[P.Pair[GU, U]], U, V any](fab GUV, ma GU) GV { - return Ap[GUV, GV, GU](ma)(fab) + return Ap[GUV, GV](ma)(fab) } func FilterChain[GVV ~func() O.Option[P.Pair[GVV, GV]], GV ~func() O.Option[P.Pair[GV, V]], GU ~func() O.Option[P.Pair[GU, U]], FCT ~func(U) O.Option[GV], U, V any](f FCT) func(ma GU) GV { diff --git a/v2/iterator/stateless/generic/monad.go b/v2/iterator/stateless/generic/monad.go index 64ef765..17e3e29 100644 --- a/v2/iterator/stateless/generic/monad.go +++ b/v2/iterator/stateless/generic/monad.go @@ -24,19 +24,19 @@ import ( type iteratorMonad[A, B any, GA ~func() O.Option[P.Pair[GA, A]], GB ~func() O.Option[P.Pair[GB, B]], GAB ~func() O.Option[P.Pair[GAB, func(A) B]]] struct{} func (o *iteratorMonad[A, B, GA, GB, GAB]) Of(a A) GA { - return Of[GA, A](a) + return Of[GA](a) } func (o *iteratorMonad[A, B, GA, GB, GAB]) Map(f func(A) B) func(GA) GB { - return Map[GB, GA, func(A) B, A, B](f) + return Map[GB, GA](f) } func (o *iteratorMonad[A, B, GA, GB, GAB]) Chain(f func(A) GB) func(GA) GB { - return Chain[GB, GA, A, B](f) + return Chain[GB, GA](f) } func (o *iteratorMonad[A, B, GA, GB, GAB]) Ap(fa GA) func(GAB) GB { - return Ap[GAB, GB, GA, A, B](fa) + return Ap[GAB, GB](fa) } // Monad implements the monadic operations for iterators diff --git a/v2/iterator/stateless/io.go b/v2/iterator/stateless/io.go index eae3048..c878f2e 100644 --- a/v2/iterator/stateless/io.go +++ b/v2/iterator/stateless/io.go @@ -23,10 +23,10 @@ import ( // FromLazy returns an [Iterator] on top of a lazy function func FromLazy[U any](l L.Lazy[U]) Iterator[U] { - return G.FromLazy[Iterator[U], L.Lazy[U]](l) + return G.FromLazy[Iterator[U]](l) } // FromIO returns an [Iterator] on top of an IO function func FromIO[U any](io IO.IO[U]) Iterator[U] { - return G.FromLazy[Iterator[U], IO.IO[U]](io) + return G.FromLazy[Iterator[U]](io) } diff --git a/v2/iterator/stateless/iterator.go b/v2/iterator/stateless/iterator.go index 67dcd82..3030c92 100644 --- a/v2/iterator/stateless/iterator.go +++ b/v2/iterator/stateless/iterator.go @@ -60,7 +60,7 @@ func Reduce[U, V any](f func(V, U) V, initial V) func(Iterator[U]) V { // MonadMap transforms an [Iterator] of type [U] into an [Iterator] of type [V] via a mapping function func MonadMap[U, V any](ma Iterator[U], f func(U) V) Iterator[V] { - return G.MonadMap[Iterator[V], Iterator[U]](ma, f) + return G.MonadMap[Iterator[V]](ma, f) } // Map transforms an [Iterator] of type [U] into an [Iterator] of type [V] via a mapping function @@ -69,7 +69,7 @@ func Map[U, V any](f func(U) V) Operator[U, V] { } func MonadChain[U, V any](ma Iterator[U], f Kleisli[U, V]) Iterator[V] { - return G.MonadChain[Iterator[V], Iterator[U]](ma, f) + return G.MonadChain(ma, f) } func Chain[U, V any](f Kleisli[U, V]) Kleisli[Iterator[U], V] { @@ -78,7 +78,7 @@ func Chain[U, V any](f Kleisli[U, V]) Kleisli[Iterator[U], V] { // Flatten converts an [Iterator] of [Iterator] into a simple [Iterator] func Flatten[U any](ma Iterator[Iterator[U]]) Iterator[U] { - return G.Flatten[Iterator[Iterator[U]], Iterator[U]](ma) + return G.Flatten(ma) } // From constructs an [Iterator] from a set of variadic arguments @@ -134,7 +134,7 @@ func FilterChain[U, V any](f func(U) O.Option[Iterator[V]]) Operator[U, V] { // FoldMap maps and folds an iterator. Map the iterator passing each value to the iterating function. Then fold the results using the provided Monoid. func FoldMap[U, V any](m M.Monoid[V]) func(func(U) V) func(ma Iterator[U]) V { - return G.FoldMap[Iterator[U], func(U) V, U, V](m) + return G.FoldMap[Iterator[U], func(U) V](m) } // Fold folds the iterator using the provided Monoid. @@ -143,9 +143,9 @@ func Fold[U any](m M.Monoid[U]) func(Iterator[U]) U { } func MonadChainFirst[U, V any](ma Iterator[U], f Kleisli[U, V]) Iterator[U] { - return G.MonadChainFirst[Iterator[V], Iterator[U], U, V](ma, f) + return G.MonadChainFirst(ma, f) } func ChainFirst[U, V any](f Kleisli[U, V]) Operator[U, U] { - return G.ChainFirst[Iterator[V], Iterator[U], U, V](f) + return G.ChainFirst[Iterator[V], Iterator[U]](f) } diff --git a/v2/iterator/stateless/last.go b/v2/iterator/stateless/last.go index 0e45cb2..771099e 100644 --- a/v2/iterator/stateless/last.go +++ b/v2/iterator/stateless/last.go @@ -23,5 +23,5 @@ import ( // Last returns the last item in an iterator if such an item exists // Note that the function will consume the [Iterator] in this call completely, to identify the last element. Do not use this for infinite iterators func Last[U any](mu Iterator[U]) O.Option[U] { - return G.Last[Iterator[U]](mu) + return G.Last(mu) } diff --git a/v2/iterator/stateless/scan.go b/v2/iterator/stateless/scan.go index b9219c7..13ea303 100644 --- a/v2/iterator/stateless/scan.go +++ b/v2/iterator/stateless/scan.go @@ -23,5 +23,5 @@ import ( // of the new [Iterator] are the result of the application of `f` to the value of the // source iterator with the previously accumulated value func Scan[FCT ~func(V, U) V, U, V any](f FCT, initial V) func(ma Iterator[U]) Iterator[V] { - return G.Scan[Iterator[V], Iterator[U], FCT](f, initial) + return G.Scan[Iterator[V], Iterator[U]](f, initial) } diff --git a/v2/iterator/stateless/uniq.go b/v2/iterator/stateless/uniq.go index 8ec8e73..a0eb7a6 100644 --- a/v2/iterator/stateless/uniq.go +++ b/v2/iterator/stateless/uniq.go @@ -22,11 +22,11 @@ import ( // StrictUniq converts an [Iterator] of arbitrary items into an [Iterator] or unique items // where uniqueness is determined by the built-in uniqueness constraint func StrictUniq[A comparable](as Iterator[A]) Iterator[A] { - return G.StrictUniq[Iterator[A]](as) + return G.StrictUniq(as) } // Uniq converts an [Iterator] of arbitrary items into an [Iterator] or unique items // where uniqueness is determined based on a key extractor function func Uniq[A any, K comparable](f func(A) K) func(as Iterator[A]) Iterator[A] { - return G.Uniq[Iterator[A], K](f) + return G.Uniq[Iterator[A]](f) } diff --git a/v2/lazy/lazy_test.go b/v2/lazy/lazy_test.go index 9212b5b..c178fdf 100644 --- a/v2/lazy/lazy_test.go +++ b/v2/lazy/lazy_test.go @@ -36,7 +36,7 @@ func TestChain(t *testing.T) { } func TestAp(t *testing.T) { - assert.Equal(t, 2, F.Pipe1(Of(utils.Double), Ap[int, int](Of(1)))()) + assert.Equal(t, 2, F.Pipe1(Of(utils.Double), Ap[int](Of(1)))()) } func TestFlatten(t *testing.T) { diff --git a/v2/lazy/traverse.go b/v2/lazy/traverse.go index ea63a26..ef59744 100644 --- a/v2/lazy/traverse.go +++ b/v2/lazy/traverse.go @@ -51,7 +51,7 @@ func TraverseRecord[K comparable, A, B any](f Kleisli[A, B]) Kleisli[map[K]A, ma // TraverseRecord applies a function returning an [IO] to all elements in a record and the // transforms this into an [IO] of that record func TraverseRecordWithIndex[K comparable, A, B any](f func(K, A) Lazy[B]) Kleisli[map[K]A, map[K]B] { - return io.TraverseRecordWithIndex[K](f) + return io.TraverseRecordWithIndex(f) } // SequenceRecord converts a record of [IO] to an [IO] of a record diff --git a/v2/monoid/function.go b/v2/monoid/function.go index 1ea7695..197beb3 100644 --- a/v2/monoid/function.go +++ b/v2/monoid/function.go @@ -65,7 +65,7 @@ import ( // assert.Equal(t, f1("test"), funcMonoid.Concat(f1, funcMonoid.Empty())("test")) func FunctionMonoid[A, B any](m Monoid[B]) Monoid[func(A) B] { return MakeMonoid( - S.FunctionSemigroup[A, B](m).Concat, + S.FunctionSemigroup[A](m).Concat, F.Constant1[A](m.Empty()), ) } diff --git a/v2/monoid/monoid.go b/v2/monoid/monoid.go index c57623c..48d3c2f 100644 --- a/v2/monoid/monoid.go +++ b/v2/monoid/monoid.go @@ -117,7 +117,7 @@ func MakeMonoid[A any](c func(A, A) A, e A) Monoid[A] { // reversed := Reverse(stringMonoid) // result := reversed.Concat("Hello", "World") // "WorldHello" func Reverse[A any](m Monoid[A]) Monoid[A] { - return MakeMonoid(S.Reverse[A](m).Concat, m.Empty()) + return MakeMonoid(S.Reverse(m).Concat, m.Empty()) } // ToSemigroup converts a Monoid to a Semigroup by discarding the identity element. diff --git a/v2/monoid/monoid_test.go b/v2/monoid/monoid_test.go index 955e6f0..bf98a28 100644 --- a/v2/monoid/monoid_test.go +++ b/v2/monoid/monoid_test.go @@ -371,7 +371,7 @@ func TestFunctionMonoid(t *testing.T) { 0, ) - funcMonoid := FunctionMonoid[string, int](intAddMonoid) + funcMonoid := FunctionMonoid[string](intAddMonoid) // Create some functions f1 := func(s string) int { return len(s) } @@ -408,7 +408,7 @@ func TestFunctionMonoid_DifferentTypes(t *testing.T) { false, ) - funcMonoid := FunctionMonoid[int, bool](boolOrMonoid) + funcMonoid := FunctionMonoid[int](boolOrMonoid) isEven := func(n int) bool { return n%2 == 0 } isPositive := func(n int) bool { return n > 0 } @@ -702,7 +702,7 @@ func BenchmarkFunctionMonoid(b *testing.B) { 0, ) - funcMonoid := FunctionMonoid[string, int](intAddMonoid) + funcMonoid := FunctionMonoid[string](intAddMonoid) f1 := func(s string) int { return len(s) } f2 := func(s string) int { return len(s) * 2 } diff --git a/v2/number/integer/ord.go b/v2/number/integer/ord.go index 3070f13..58d543a 100644 --- a/v2/number/integer/ord.go +++ b/v2/number/integer/ord.go @@ -23,4 +23,4 @@ import ( var Ord = O.FromStrictCompare[int]() // Between checks if an integer is between two values -var Between = O.Between[int](Ord) +var Between = O.Between(Ord) diff --git a/v2/number/number_test.go b/v2/number/number_test.go index 9ef185a..18c0e12 100644 --- a/v2/number/number_test.go +++ b/v2/number/number_test.go @@ -393,7 +393,7 @@ func TestDiv(t *testing.T) { // Test Div with floats func TestDiv_Float(t *testing.T) { - half := Div[float64](2.0) + half := Div(2.0) assert.Equal(t, 5.0, half(10.0)) assert.Equal(t, 2.5, half(5.0)) diff --git a/v2/optics/iso/iso.go b/v2/optics/iso/iso.go index 5b81cea..7707065 100644 --- a/v2/optics/iso/iso.go +++ b/v2/optics/iso/iso.go @@ -318,7 +318,7 @@ func Wrap[S, A any](a A) func(Iso[S, A]) S { // email := To[Email](ValidatedEmail{value: "user@example.com"})(emailIso) // // "user@example.com" func To[A, S any](s S) func(Iso[S, A]) A { - return Unwrap[A, S](s) + return Unwrap[A](s) } // From wraps a target value into a source value using an isomorphism. diff --git a/v2/optics/iso/iso_test.go b/v2/optics/iso/iso_test.go index 0e53d9b..7448853 100644 --- a/v2/optics/iso/iso_test.go +++ b/v2/optics/iso/iso_test.go @@ -44,8 +44,8 @@ var ( func TestGet(t *testing.T) { assert.Equal(t, mToKm.Get(100), float32(0.1)) - assert.Equal(t, Unwrap[float32, float32](float32(100))(mToKm), float32(0.1)) - assert.Equal(t, To[float32, float32](float32(100))(mToKm), float32(0.1)) + assert.Equal(t, Unwrap[float32](float32(100))(mToKm), float32(0.1)) + assert.Equal(t, To[float32](float32(100))(mToKm), float32(0.1)) } func TestReverseGet(t *testing.T) { @@ -94,7 +94,7 @@ func TestIMap(t *testing.T) { ) // Map to a different representation (string) - kmToString := IMap[float32, float32, string]( + kmToString := IMap[float32]( func(km float32) string { return fmt.Sprintf("%.2f km", km) }, func(s string) float32 { var km float32 diff --git a/v2/optics/lens/array/generic/head.go b/v2/optics/lens/array/generic/head.go index 4899207..b46108e 100644 --- a/v2/optics/lens/array/generic/head.go +++ b/v2/optics/lens/array/generic/head.go @@ -29,7 +29,7 @@ func AtHead[AS []A, A any]() L.Lens[AS, O.Option[A]] { return L.MakeLens(AA.Head[AS, A], func(as AS, a O.Option[A]) AS { return O.MonadFold(a, AA.Empty[AS], func(v A) AS { if AA.IsEmpty(as) { - return AA.Of[AS, A](v) + return AA.Of[AS](v) } cpy := AA.Copy(as) cpy[0] = v diff --git a/v2/optics/lens/lens_test.go b/v2/optics/lens/lens_test.go index 00cb19c..ef32d7a 100644 --- a/v2/optics/lens/lens_test.go +++ b/v2/optics/lens/lens_test.go @@ -185,7 +185,7 @@ func TestIdRef(t *testing.T) { } func TestComposeRef(t *testing.T) { - composedLens := ComposeRef[Address, *Street](streetLens)(addrLens) + composedLens := ComposeRef[Address](streetLens)(addrLens) assert.Equal(t, sampleStreet.name, composedLens.Get(&sampleAddress)) diff --git a/v2/optics/lens/record/generic/record.go b/v2/optics/lens/record/generic/record.go index 8db769c..987af01 100644 --- a/v2/optics/lens/record/generic/record.go +++ b/v2/optics/lens/record/generic/record.go @@ -37,7 +37,7 @@ func AtRecord[M ~map[K]V, V any, K comparable](key K) L.Lens[M, O.Option[V]] { return F.Pipe2( v, fold, - I.Ap[M, M](m), + I.Ap[M](m), ) }, ) diff --git a/v2/optics/prism/prism_test.go b/v2/optics/prism/prism_test.go index 75428c3..a11c105 100644 --- a/v2/optics/prism/prism_test.go +++ b/v2/optics/prism/prism_test.go @@ -102,11 +102,11 @@ func TestSet(t *testing.T) { ) // Set value when it matches - result := Set[Option[int], int](100)(somePrism)(O.Some(42)) + result := Set[Option[int]](100)(somePrism)(O.Some(42)) assert.Equal(t, O.Some(100), result) // No change when it doesn't match - result = Set[Option[int], int](100)(somePrism)(O.None[int]()) + result = Set[Option[int]](100)(somePrism)(O.None[int]()) assert.Equal(t, O.None[int](), result) } @@ -211,7 +211,7 @@ func TestPrismModifyOption(t *testing.T) { ) // Modify when match - setFn := Set[Option[int], int](100) + setFn := Set[Option[int]](100) result := setFn(somePrism)(O.Some(42)) assert.Equal(t, O.Some(100), result) @@ -255,7 +255,7 @@ func TestPrismWithCustomType(t *testing.T) { assert.Equal(t, testSuccess{Value: 100}, result) // Test Set with Success - setFn := Set[testResult, int](200) + setFn := Set[testResult](200) updated := setFn(successPrism)(success) assert.Equal(t, testSuccess{Value: 200}, updated) @@ -272,11 +272,11 @@ func TestPrismModify(t *testing.T) { ) // Test modify with matching value - result := Set[Option[int], int](84)(somePrism)(O.Some(42)) + result := Set[Option[int]](84)(somePrism)(O.Some(42)) assert.Equal(t, O.Some(84), result) // Test that original is returned when no match - result = Set[Option[int], int](100)(somePrism)(O.None[int]()) + result = Set[Option[int]](100)(somePrism)(O.None[int]()) assert.Equal(t, O.None[int](), result) } @@ -286,7 +286,7 @@ func TestPrismModifyWithTransform(t *testing.T) { positivePrism := FromPredicate(func(n int) bool { return n > 0 }) // Modify positive number - setter := Set[int, int](100) + setter := Set[int](100) result := setter(positivePrism)(42) assert.Equal(t, 100, result) @@ -395,9 +395,9 @@ func TestPrismSetMultipleTimes(t *testing.T) { // Chain multiple sets result := F.Pipe3( O.Some(10), - Set[Option[int], int](20)(somePrism), - Set[Option[int], int](30)(somePrism), - Set[Option[int], int](40)(somePrism), + Set[Option[int]](20)(somePrism), + Set[Option[int]](30)(somePrism), + Set[Option[int]](40)(somePrism), ) assert.Equal(t, O.Some(40), result) @@ -686,7 +686,7 @@ func TestFromEncodingWithSet(t *testing.T) { // New data to set newData := []byte("New Data") - setter := Set[string, []byte](newData) + setter := Set[string](newData) // Apply the setter result := setter(prism)(original) @@ -707,7 +707,7 @@ func TestFromEncodingWithSet(t *testing.T) { // Try to set new data newData := []byte("New Data") - setter := Set[string, []byte](newData) + setter := Set[string](newData) // Should return original unchanged result := setter(prism)(invalid) @@ -900,7 +900,7 @@ func TestParseURLWithSet(t *testing.T) { original := "https://oldsite.com/path" newURL, _ := url.Parse("https://newsite.com/newpath") - setter := Set[string, *url.URL](newURL) + setter := Set[string](newURL) result := setter(urlPrism)(original) assert.Equal(t, "https://newsite.com/newpath", result) @@ -1027,7 +1027,7 @@ func TestInstanceOfWithSet(t *testing.T) { intPrism := InstanceOf[int]() var original any = 42 - setter := Set[any, int](100) + setter := Set[any](100) result := setter(intPrism)(original) assert.Equal(t, any(100), result) @@ -1037,7 +1037,7 @@ func TestInstanceOfWithSet(t *testing.T) { intPrism := InstanceOf[int]() var original any = "not an int" - setter := Set[any, int](100) + setter := Set[any](100) result := setter(intPrism)(original) assert.Equal(t, original, result) @@ -1166,7 +1166,7 @@ func TestParseDateWithSet(t *testing.T) { original := "2024-03-15" newDate := time.Date(2025, 1, 1, 0, 0, 0, 0, time.UTC) - setter := Set[string, time.Time](newDate) + setter := Set[string](newDate) result := setter(datePrism)(original) assert.Equal(t, "2025-01-01", result) @@ -1176,7 +1176,7 @@ func TestParseDateWithSet(t *testing.T) { invalid := "not-a-date" newDate := time.Date(2025, 1, 1, 0, 0, 0, 0, time.UTC) - setter := Set[string, time.Time](newDate) + setter := Set[string](newDate) result := setter(datePrism)(invalid) assert.Equal(t, invalid, result) @@ -1317,7 +1317,7 @@ func TestDerefWithSet(t *testing.T) { newValue := 100 newPtr := &newValue - setter := Set[*int, *int](newPtr) + setter := Set[*int](newPtr) result := setter(derefPrism)(ptr) assert.NotNil(t, result) @@ -1330,7 +1330,7 @@ func TestDerefWithSet(t *testing.T) { newValue := 100 newPtr := &newValue - setter := Set[*int, *int](newPtr) + setter := Set[*int](newPtr) result := setter(derefPrism)(nilPtr) assert.Nil(t, result) @@ -1439,7 +1439,7 @@ func TestFromEitherWithSet(t *testing.T) { t.Run("set on Right value", func(t *testing.T) { success := E.Right[error](42) - setter := Set[E.Either[error, int], int](100) + setter := Set[E.Either[error, int]](100) result := setter(prism)(success) assert.True(t, E.IsRight(result)) @@ -1450,7 +1450,7 @@ func TestFromEitherWithSet(t *testing.T) { t.Run("set on Left value returns original", func(t *testing.T) { failure := E.Left[int](errors.New("failed")) - setter := Set[E.Either[error, int], int](100) + setter := Set[E.Either[error, int]](100) result := setter(prism)(failure) assert.True(t, E.IsLeft(result)) diff --git a/v2/optics/prism/prisms_test.go b/v2/optics/prism/prisms_test.go index c46a5b3..ab39adf 100644 --- a/v2/optics/prism/prisms_test.go +++ b/v2/optics/prism/prisms_test.go @@ -115,7 +115,7 @@ func TestFromZeroWithSet(t *testing.T) { t.Run("set on zero value", func(t *testing.T) { prism := FromZero[int]() - setter := Set[int, int](100) + setter := Set[int](100) result := setter(prism)(0) assert.Equal(t, 100, result) @@ -124,7 +124,7 @@ func TestFromZeroWithSet(t *testing.T) { t.Run("set on non-zero returns original", func(t *testing.T) { prism := FromZero[int]() - setter := Set[int, int](100) + setter := Set[int](100) result := setter(prism)(42) assert.Equal(t, 42, result) @@ -467,7 +467,7 @@ func TestRegexMatcherWithSet(t *testing.T) { After: " dollars", } - setter := Set[string, Match](newMatch) + setter := Set[string](newMatch) result := setter(prism)(original) assert.Equal(t, "price: 100 dollars", result) @@ -482,7 +482,7 @@ func TestRegexMatcherWithSet(t *testing.T) { After: "", } - setter := Set[string, Match](newMatch) + setter := Set[string](newMatch) result := setter(prism)(original) assert.Equal(t, original, result) @@ -507,7 +507,7 @@ func TestRegexNamedMatcherWithSet(t *testing.T) { After: "", } - setter := Set[string, NamedMatch](newMatch) + setter := Set[string](newMatch) result := setter(prism)(original) assert.Equal(t, "email: admin@newsite.com", result) @@ -526,7 +526,7 @@ func TestRegexNamedMatcherWithSet(t *testing.T) { After: "", } - setter := Set[string, NamedMatch](newMatch) + setter := Set[string](newMatch) result := setter(prism)(original) assert.Equal(t, original, result) diff --git a/v2/optics/traversal/array/const/traversal.go b/v2/optics/traversal/array/const/traversal.go index 9d36a7f..ab6bd00 100644 --- a/v2/optics/traversal/array/const/traversal.go +++ b/v2/optics/traversal/array/const/traversal.go @@ -24,5 +24,5 @@ import ( // FromArray returns a traversal from an array for the identity [Monoid] func FromArray[E, A any](m M.Monoid[E]) G.Traversal[[]A, A, C.Const[E, []A], C.Const[E, A]] { - return AR.FromArray[[]A, E, A](m) + return AR.FromArray[[]A](m) } diff --git a/v2/optics/traversal/array/generic/const/traversal.go b/v2/optics/traversal/array/generic/const/traversal.go index cbf2bed..53ec8ee 100644 --- a/v2/optics/traversal/array/generic/const/traversal.go +++ b/v2/optics/traversal/array/generic/const/traversal.go @@ -24,7 +24,7 @@ import ( // FromArray returns a traversal from an array for the const monad func FromArray[GA ~[]A, E, A any](m M.Monoid[E]) G.Traversal[GA, A, C.Const[E, GA], C.Const[E, A]] { - return AR.FromArray[GA, GA, A, A, C.Const[E, A], C.Const[E, func(A) GA], C.Const[E, GA]]( + return AR.FromArray[GA]( C.Of[E, GA](m), C.Map[E, GA, func(A) GA], C.Ap[E, A, GA](m), diff --git a/v2/optics/traversal/array/generic/identity/traversal.go b/v2/optics/traversal/array/generic/identity/traversal.go index 7763fe8..0609a5a 100644 --- a/v2/optics/traversal/array/generic/identity/traversal.go +++ b/v2/optics/traversal/array/generic/identity/traversal.go @@ -23,7 +23,7 @@ import ( // FromArray returns a traversal from an array for the identity monad func FromArray[GA ~[]A, A any]() G.Traversal[GA, A, GA, A] { - return AR.FromArray[GA, GA, A, A, A, func(A) GA, GA]( + return AR.FromArray[GA]( I.Of[GA], I.Map[GA, func(A) GA], I.Ap[GA, A], diff --git a/v2/optics/traversal/array/identity/traversal.go b/v2/optics/traversal/array/identity/traversal.go index 5b1d1c8..ffda1f2 100644 --- a/v2/optics/traversal/array/identity/traversal.go +++ b/v2/optics/traversal/array/identity/traversal.go @@ -22,5 +22,5 @@ import ( // FromArray returns a traversal from an array for the identity monad func FromArray[A any]() G.Traversal[[]A, A, []A, A] { - return AR.FromArray[[]A, A]() + return AR.FromArray[[]A]() } diff --git a/v2/optics/traversal/generic/traversal.go b/v2/optics/traversal/generic/traversal.go index 730a857..97f6635 100644 --- a/v2/optics/traversal/generic/traversal.go +++ b/v2/optics/traversal/generic/traversal.go @@ -61,12 +61,12 @@ func FoldMap[M, S, A any](f func(A) M) func(sa Traversal[S, A, C.Const[M, S], C. // Fold maps each target to a `Monoid` and combines the result func Fold[S, A any](sa Traversal[S, A, C.Const[A, S], C.Const[A, A]]) func(S) A { - return FoldMap[A, S, A](F.Identity[A])(sa) + return FoldMap[A, S](F.Identity[A])(sa) } // GetAll gets all the targets of a traversal func GetAll[GA ~[]A, S, A any](s S) func(sa Traversal[S, A, C.Const[GA, S], C.Const[GA, A]]) GA { - fmap := FoldMap[GA, S, A](AR.Of[GA, A]) + fmap := FoldMap[GA, S](AR.Of[GA, A]) return func(sa Traversal[S, A, C.Const[GA, S], C.Const[GA, A]]) GA { return fmap(sa)(s) } diff --git a/v2/optics/traversal/record/const/traversal.go b/v2/optics/traversal/record/const/traversal.go index 34bca46..e57f19d 100644 --- a/v2/optics/traversal/record/const/traversal.go +++ b/v2/optics/traversal/record/const/traversal.go @@ -24,5 +24,5 @@ import ( // FromRecord returns a traversal from an array for the const monad func FromRecord[E, K comparable, A any](m M.Monoid[E]) G.Traversal[map[K]A, A, C.Const[E, map[K]A], C.Const[E, A]] { - return RR.FromRecord[map[K]A, E, K, A](m) + return RR.FromRecord[map[K]A](m) } diff --git a/v2/optics/traversal/record/generic/const/traversal.go b/v2/optics/traversal/record/generic/const/traversal.go index c71483a..f7d3856 100644 --- a/v2/optics/traversal/record/generic/const/traversal.go +++ b/v2/optics/traversal/record/generic/const/traversal.go @@ -24,7 +24,7 @@ import ( // FromRecord returns a traversal from an array for the const monad func FromRecord[MA ~map[K]A, E, K comparable, A any](m M.Monoid[E]) G.Traversal[MA, A, C.Const[E, MA], C.Const[E, A]] { - return RR.FromRecord[MA, MA, K, A, A, C.Const[E, A], C.Const[E, func(A) MA], C.Const[E, MA]]( + return RR.FromRecord[MA]( C.Of[E, MA](m), C.Map[E, MA, func(A) MA], C.Ap[E, A, MA](m), diff --git a/v2/optics/traversal/record/generic/identity/traversal.go b/v2/optics/traversal/record/generic/identity/traversal.go index a6640c6..63482ff 100644 --- a/v2/optics/traversal/record/generic/identity/traversal.go +++ b/v2/optics/traversal/record/generic/identity/traversal.go @@ -23,7 +23,7 @@ import ( // FromRecord returns a traversal from a record for the identity monad func FromRecord[MA ~map[K]A, K comparable, A any]() G.Traversal[MA, A, MA, A] { - return RR.FromRecord[MA, MA, K, A, A, A, func(A) MA, MA]( + return RR.FromRecord[MA]( I.Of[MA], I.Map[MA, func(A) MA], I.Ap[MA, A], diff --git a/v2/optics/traversal/record/identity/traversal.go b/v2/optics/traversal/record/identity/traversal.go index b4d66b1..5b09972 100644 --- a/v2/optics/traversal/record/identity/traversal.go +++ b/v2/optics/traversal/record/identity/traversal.go @@ -22,5 +22,5 @@ import ( // FromRecord returns a traversal from an array for the identity monad func FromRecord[K comparable, A any]() G.Traversal[map[K]A, A, map[K]A, A] { - return RR.FromRecord[map[K]A, K, A]() + return RR.FromRecord[map[K]A]() } diff --git a/v2/optics/traversal/traversal.go b/v2/optics/traversal/traversal.go index bb716c6..33de128 100644 --- a/v2/optics/traversal/traversal.go +++ b/v2/optics/traversal/traversal.go @@ -35,22 +35,22 @@ func Modify[S, A any](f func(A) A) func(sa G.Traversal[S, A, S, A]) func(S) S { // Set sets a constant value for all values of the traversal func Set[S, A any](a A) func(sa G.Traversal[S, A, S, A]) func(S) S { - return Modify[S, A](F.Constant1[A](a)) + return Modify[S](F.Constant1[A](a)) } // FoldMap maps each target to a `Monoid` and combines the result func FoldMap[M, S, A any](f func(A) M) func(sa G.Traversal[S, A, C.Const[M, S], C.Const[M, A]]) func(S) M { - return G.FoldMap[M, S, A](f) + return G.FoldMap[M, S](f) } // Fold maps each target to a `Monoid` and combines the result func Fold[S, A any](sa G.Traversal[S, A, C.Const[A, S], C.Const[A, A]]) func(S) A { - return G.Fold[S, A](sa) + return G.Fold(sa) } // GetAll gets all the targets of a traversal func GetAll[S, A any](s S) func(sa G.Traversal[S, A, C.Const[[]A, S], C.Const[[]A, A]]) []A { - return G.GetAll[[]A, S, A](s) + return G.GetAll[[]A](s) } // Compose composes two traversables diff --git a/v2/optics/traversal/traversal_test.go b/v2/optics/traversal/traversal_test.go index 8de88d8..14ba1ff 100644 --- a/v2/optics/traversal/traversal_test.go +++ b/v2/optics/traversal/traversal_test.go @@ -57,7 +57,7 @@ func TestFold(t *testing.T) { Compose[[]int, []int, int, C.Const[int, []int]](tr), ) - folded := Fold[[]int, int](sa)(as) + folded := Fold(sa)(as) assert.Equal(t, 6, folded) } @@ -70,7 +70,7 @@ func TestTraverse(t *testing.T) { sa := F.Pipe1( Id[[]int, []int](), - Compose[[]int, []int, int, []int, []int, int](tr), + Compose[[]int, []int, int, []int](tr), ) res := sa(utils.Double)(as) diff --git a/v2/option/bind.go b/v2/option/bind.go index 401a298..40e9c7b 100644 --- a/v2/option/bind.go +++ b/v2/option/bind.go @@ -229,7 +229,7 @@ func BindL[S, T any]( lens L.Lens[S, T], f Kleisli[T, T], ) Kleisli[Option[S], S] { - return Bind[S, S, T](lens.Set, function.Flow2(lens.Get, f)) + return Bind(lens.Set, function.Flow2(lens.Get, f)) } // LetL attaches the result of a pure computation to a context using a lens-based setter. @@ -265,7 +265,7 @@ func LetL[S, T any]( lens L.Lens[S, T], f func(T) T, ) Kleisli[Option[S], S] { - return Let[S, S, T](lens.Set, function.Flow2(lens.Get, f)) + return Let(lens.Set, function.Flow2(lens.Get, f)) } // LetToL attaches a constant value to a context using a lens-based setter. @@ -299,5 +299,5 @@ func LetToL[S, T any]( lens L.Lens[S, T], b T, ) Kleisli[Option[S], S] { - return LetTo[S, S, T](lens.Set, b) + return LetTo(lens.Set, b) } diff --git a/v2/option/functor.go b/v2/option/functor.go index d571fa1..916fec5 100644 --- a/v2/option/functor.go +++ b/v2/option/functor.go @@ -22,7 +22,7 @@ import ( type optionFunctor[A, B any] struct{} func (o *optionFunctor[A, B]) Map(f func(A) B) Operator[A, B] { - return Map[A, B](f) + return Map(f) } // Functor implements the functoric operations for Option. diff --git a/v2/option/monad.go b/v2/option/monad.go index 3c471e4..67ece0b 100644 --- a/v2/option/monad.go +++ b/v2/option/monad.go @@ -22,19 +22,19 @@ import ( type optionMonad[A, B any] struct{} func (o *optionMonad[A, B]) Of(a A) Option[A] { - return Of[A](a) + return Of(a) } func (o *optionMonad[A, B]) Map(f func(A) B) Operator[A, B] { - return Map[A, B](f) + return Map(f) } func (o *optionMonad[A, B]) Chain(f Kleisli[A, B]) Operator[A, B] { - return Chain[A, B](f) + return Chain(f) } func (o *optionMonad[A, B]) Ap(fa Option[A]) func(Option[func(A) B]) Option[B] { - return Ap[B, A](fa) + return Ap[B](fa) } // Monad implements the monadic operations for Option. diff --git a/v2/option/option_extended_test.go b/v2/option/option_extended_test.go index 2ff9b24..dd8e6e7 100644 --- a/v2/option/option_extended_test.go +++ b/v2/option/option_extended_test.go @@ -82,7 +82,7 @@ func TestMonadMapTo(t *testing.T) { // Test MapTo func TestMapTo(t *testing.T) { - replaceWith42 := MapTo[string, int](42) + replaceWith42 := MapTo[string](42) assert.Equal(t, Some(42), replaceWith42(Some("hello"))) assert.Equal(t, None[int](), replaceWith42(None[string]())) } @@ -126,7 +126,7 @@ func TestMonadChainTo(t *testing.T) { // Test ChainTo func TestChainTo(t *testing.T) { - replaceWith := ChainTo[int, string](Some("hello")) + replaceWith := ChainTo[int](Some("hello")) assert.Equal(t, Some("hello"), replaceWith(Some(42))) assert.Equal(t, Some("hello"), replaceWith(None[int]())) } diff --git a/v2/option/option_test.go b/v2/option/option_test.go index e172058..e9babf6 100644 --- a/v2/option/option_test.go +++ b/v2/option/option_test.go @@ -102,22 +102,22 @@ func TestTryCachOption(t *testing.T) { func TestAp(t *testing.T) { assert.Equal(t, Some(4), F.Pipe1( Some(utils.Double), - Ap[int, int](Some(2)), + Ap[int](Some(2)), )) assert.Equal(t, None[int](), F.Pipe1( Some(utils.Double), - Ap[int, int](None[int]()), + Ap[int](None[int]()), )) assert.Equal(t, None[int](), F.Pipe1( None[func(int) int](), - Ap[int, int](Some(2)), + Ap[int](Some(2)), )) assert.Equal(t, None[int](), F.Pipe1( None[func(int) int](), - Ap[int, int](None[int]()), + Ap[int](None[int]()), )) } diff --git a/v2/option/pointed.go b/v2/option/pointed.go index 624aa98..c3e76ef 100644 --- a/v2/option/pointed.go +++ b/v2/option/pointed.go @@ -22,7 +22,7 @@ import ( type optionPointed[A any] struct{} func (o *optionPointed[A]) Of(a A) Option[A] { - return Of[A](a) + return Of(a) } // Pointed implements the Pointed operations for Option. diff --git a/v2/pair/pair_test.go b/v2/pair/pair_test.go index 1810f56..ca72534 100644 --- a/v2/pair/pair_test.go +++ b/v2/pair/pair_test.go @@ -376,7 +376,7 @@ func TestPointedHead(t *testing.T) { func(a, b string) string { return a + b }, "", ) - pointed := PointedHead[int, string](stringMonoid) + pointed := PointedHead[int](stringMonoid) p := pointed.Of(42) assert.Equal(t, 42, Head(p)) assert.Equal(t, "", Tail(p)) @@ -452,7 +452,7 @@ func TestMonadTail(t *testing.T) { func TestPointedTail(t *testing.T) { intSum := N.MonoidSum[int]() - pointed := PointedTail[string, int](intSum) + pointed := PointedTail[string](intSum) p := pointed.Of("test") assert.Equal(t, 0, Head(p)) assert.Equal(t, "test", Tail(p)) @@ -502,7 +502,7 @@ func TestMonad(t *testing.T) { func TestPointed(t *testing.T) { intSum := N.MonoidSum[int]() - pointed := Pointed[string, int](intSum) + pointed := Pointed[string](intSum) p := pointed.Of("hello") assert.Equal(t, 0, Head(p)) diff --git a/v2/reader/array.go b/v2/reader/array.go index 9ff6942..9755aa9 100644 --- a/v2/reader/array.go +++ b/v2/reader/array.go @@ -38,7 +38,7 @@ import ( // r := reader.MonadTraverseArray(numbers, addPrefix) // result := r(Config{Prefix: "num"}) // ["num1", "num2", "num3"] func MonadTraverseArray[R, A, B any](ma []A, f Kleisli[R, A, B]) Reader[R, []B] { - return array.MonadTraverse[[]A]( + return array.MonadTraverse( Of[R, []B], Map[R, []B, func(B) []B], Ap[[]B, R, B], diff --git a/v2/reader/bind.go b/v2/reader/bind.go index 2f6e856..eaf5ca5 100644 --- a/v2/reader/bind.go +++ b/v2/reader/bind.go @@ -286,7 +286,7 @@ func BindL[R, S, T any]( lens L.Lens[S, T], f Kleisli[R, T, T], ) Operator[R, S, S] { - return Bind[R, S, S, T](lens.Set, F.Flow2(lens.Get, f)) + return Bind(lens.Set, F.Flow2(lens.Get, f)) } // LetL is a variant of Let that uses a lens to focus on a specific part of the context. @@ -324,7 +324,7 @@ func LetL[R, S, T any]( lens L.Lens[S, T], f func(T) T, ) Operator[R, S, S] { - return Let[R, S, S, T](lens.Set, F.Flow2(lens.Get, f)) + return Let[R](lens.Set, F.Flow2(lens.Get, f)) } // LetToL is a variant of LetTo that uses a lens to focus on a specific part of the context. @@ -359,5 +359,5 @@ func LetToL[R, S, T any]( lens L.Lens[S, T], b T, ) Operator[R, S, S] { - return LetTo[R, S, S, T](lens.Set, b) + return LetTo[R](lens.Set, b) } diff --git a/v2/reader/bind_test.go b/v2/reader/bind_test.go index 2c4aaa6..e8b5078 100644 --- a/v2/reader/bind_test.go +++ b/v2/reader/bind_test.go @@ -65,7 +65,7 @@ func TestLet(t *testing.T) { res := F.Pipe2( Do[context.Context](State{FirstName: "John", LastName: "Doe"}), - Let[context.Context, State, State, string]( + Let[context.Context]( func(full string) func(State) State { return func(s State) State { s.FullName = full; return s } }, @@ -87,7 +87,7 @@ func TestLetTo(t *testing.T) { res := F.Pipe2( Do[context.Context](State{Name: "MyApp"}), - LetTo[context.Context, State, State, string]( + LetTo[context.Context]( func(v string) func(State) State { return func(s State) State { s.Version = v; return s } }, @@ -105,7 +105,7 @@ func TestBindTo(t *testing.T) { type State struct{ Name string } getName := Asks(func(c context.Context) string { return "TestName" }) - initState := BindTo[context.Context, State, string](func(name string) State { + initState := BindTo[context.Context](func(name string) State { return State{Name: name} }) result := initState(getName) diff --git a/v2/reader/generic/array.go b/v2/reader/generic/array.go index c85315a..b4a2c0a 100644 --- a/v2/reader/generic/array.go +++ b/v2/reader/generic/array.go @@ -36,7 +36,7 @@ import ( // - A: The input element type // - B: The output element type func MonadTraverseArray[GB ~func(R) B, GBS ~func(R) BBS, AAS ~[]A, BBS ~[]B, R, A, B any](tas AAS, f func(A) GB) GBS { - return RA.MonadTraverse[AAS]( + return RA.MonadTraverse( Of[GBS, R, BBS], Map[GBS, func(R) func(B) BBS, R, BBS, func(B) BBS], Ap[GB, GBS, func(R) func(B) BBS, R, B, BBS], diff --git a/v2/reader/reader.go b/v2/reader/reader.go index 6683677..fd8252e 100644 --- a/v2/reader/reader.go +++ b/v2/reader/reader.go @@ -266,7 +266,7 @@ func Promap[E, A, D, B any](f func(D) E, g func(A) B) func(Reader[E, A]) Reader[ // r := reader.Local(simplify)(getHost) // result := r(DetailedConfig{Host: "localhost", Port: 8080}) // "localhost" func Local[A, R2, R1 any](f func(R2) R1) func(Reader[R1, A]) Reader[R2, A] { - return Compose[A, R2, R1](f) + return Compose[A](f) } // Read applies a context to a Reader to obtain its value. diff --git a/v2/reader/reader_test.go b/v2/reader/reader_test.go index d08ec5a..d147337 100644 --- a/v2/reader/reader_test.go +++ b/v2/reader/reader_test.go @@ -73,7 +73,7 @@ func TestMonadMap(t *testing.T) { } func TestAp(t *testing.T) { - assert.Equal(t, 2, F.Pipe1(Of[int](utils.Double), Ap[int, int, int](Of[int](1)))(0)) + assert.Equal(t, 2, F.Pipe1(Of[int](utils.Double), Ap[int](Of[int](1)))(0)) } func TestMonadAp(t *testing.T) { @@ -142,7 +142,7 @@ func TestFirst(t *testing.T) { func TestSecond(t *testing.T) { double := func(x int) int { return x * 2 } - r := Second[string, int, int](double) + r := Second[string](double) result := r(T.MakeTuple2("hello", 5)) assert.Equal(t, T.MakeTuple2("hello", 10), result) } diff --git a/v2/readereither/bind.go b/v2/readereither/bind.go index dca061e..8669398 100644 --- a/v2/readereither/bind.go +++ b/v2/readereither/bind.go @@ -38,7 +38,7 @@ import ( func Do[R, E, S any]( empty S, ) ReaderEither[R, E, S] { - return G.Do[ReaderEither[R, E, S], R, E, S](empty) + return G.Do[ReaderEither[R, E, S]](empty) } // Bind attaches the result of a computation to a context [S1] to produce a context [S2]. @@ -87,7 +87,7 @@ func Bind[R, E, S1, S2, T any]( setter func(T) func(S1) S2, f func(S1) ReaderEither[R, E, T], ) func(ReaderEither[R, E, S1]) ReaderEither[R, E, S2] { - return G.Bind[ReaderEither[R, E, S1], ReaderEither[R, E, S2], ReaderEither[R, E, T], R, E, S1, S2, T](setter, f) + return G.Bind[ReaderEither[R, E, S1], ReaderEither[R, E, S2]](setter, f) } // Let attaches the result of a computation to a context [S1] to produce a context [S2] @@ -95,7 +95,7 @@ func Let[R, E, S1, S2, T any]( setter func(T) func(S1) S2, f func(S1) T, ) func(ReaderEither[R, E, S1]) ReaderEither[R, E, S2] { - return G.Let[ReaderEither[R, E, S1], ReaderEither[R, E, S2], R, E, S1, S2, T](setter, f) + return G.Let[ReaderEither[R, E, S1], ReaderEither[R, E, S2]](setter, f) } // LetTo attaches the a value to a context [S1] to produce a context [S2] @@ -103,14 +103,14 @@ func LetTo[R, E, S1, S2, T any]( setter func(T) func(S1) S2, b T, ) func(ReaderEither[R, E, S1]) ReaderEither[R, E, S2] { - return G.LetTo[ReaderEither[R, E, S1], ReaderEither[R, E, S2], R, E, S1, S2, T](setter, b) + return G.LetTo[ReaderEither[R, E, S1], ReaderEither[R, E, S2]](setter, b) } // BindTo initializes a new state [S1] from a value [T] func BindTo[R, E, S1, T any]( setter func(T) S1, ) func(ReaderEither[R, E, T]) ReaderEither[R, E, S1] { - return G.BindTo[ReaderEither[R, E, S1], ReaderEither[R, E, T], R, E, S1, T](setter) + return G.BindTo[ReaderEither[R, E, S1], ReaderEither[R, E, T]](setter) } // ApS attaches a value to a context [S1] to produce a context [S2] by considering @@ -158,7 +158,7 @@ func ApS[R, E, S1, S2, T any]( setter func(T) func(S1) S2, fa ReaderEither[R, E, T], ) func(ReaderEither[R, E, S1]) ReaderEither[R, E, S2] { - return G.ApS[ReaderEither[R, E, S1], ReaderEither[R, E, S2], ReaderEither[R, E, T], R, E, S1, S2, T](setter, fa) + return G.ApS[ReaderEither[R, E, S1], ReaderEither[R, E, S2]](setter, fa) } // ApSL attaches a value to a context using a lens-based setter. @@ -234,7 +234,7 @@ func BindL[R, E, S, T any]( lens L.Lens[S, T], f func(T) ReaderEither[R, E, T], ) func(ReaderEither[R, E, S]) ReaderEither[R, E, S] { - return Bind[R, E, S, S, T](lens.Set, F.Flow2(lens.Get, f)) + return Bind(lens.Set, F.Flow2(lens.Get, f)) } // LetL is a variant of Let that uses a lens to focus on a specific part of the context. @@ -268,7 +268,7 @@ func LetL[R, E, S, T any]( lens L.Lens[S, T], f func(T) T, ) func(ReaderEither[R, E, S]) ReaderEither[R, E, S] { - return Let[R, E, S, S, T](lens.Set, F.Flow2(lens.Get, f)) + return Let[R, E](lens.Set, F.Flow2(lens.Get, f)) } // LetToL is a variant of LetTo that uses a lens to focus on a specific part of the context. @@ -299,5 +299,5 @@ func LetToL[R, E, S, T any]( lens L.Lens[S, T], b T, ) func(ReaderEither[R, E, S]) ReaderEither[R, E, S] { - return LetTo[R, E, S, S, T](lens.Set, b) + return LetTo[R, E](lens.Set, b) } diff --git a/v2/readereither/generic/array.go b/v2/readereither/generic/array.go index 68794b1..7178fa0 100644 --- a/v2/readereither/generic/array.go +++ b/v2/readereither/generic/array.go @@ -23,7 +23,7 @@ import ( // MonadTraverseArray transforms an array func MonadTraverseArray[GB ~func(E) ET.Either[L, B], GBS ~func(E) ET.Either[L, BBS], AAS ~[]A, BBS ~[]B, L, E, A, B any](ma AAS, f func(A) GB) GBS { - return RA.MonadTraverse[AAS]( + return RA.MonadTraverse( Of[GBS, L, E, BBS], Map[GBS, func(E) ET.Either[L, func(B) BBS], L, E, BBS, func(B) BBS], Ap[GB, GBS, func(E) ET.Either[L, func(B) BBS], L, E, B, BBS], diff --git a/v2/readereither/generic/bind.go b/v2/readereither/generic/bind.go index 48c2ad6..ad9a707 100644 --- a/v2/readereither/generic/bind.go +++ b/v2/readereither/generic/bind.go @@ -39,7 +39,7 @@ import ( func Do[GS ~func(R) ET.Either[E, S], R, E, S any]( empty S, ) GS { - return Of[GS, E, R, S](empty) + return Of[GS](empty) } // Bind attaches the result of a computation to a context [S1] to produce a context [S2]. diff --git a/v2/readereither/reader.go b/v2/readereither/reader.go index 1c4e7ed..8145d5e 100644 --- a/v2/readereither/reader.go +++ b/v2/readereither/reader.go @@ -59,11 +59,11 @@ func Map[E, L, A, B any](f func(A) B) func(ReaderEither[E, L, A]) ReaderEither[E } func MonadChain[E, L, A, B any](ma ReaderEither[E, L, A], f func(A) ReaderEither[E, L, B]) ReaderEither[E, L, B] { - return readert.MonadChain[ReaderEither[E, L, A], ReaderEither[E, L, B]](ET.MonadChain[L, A, B], ma, f) + return readert.MonadChain(ET.MonadChain[L, A, B], ma, f) } func Chain[E, L, A, B any](f func(A) ReaderEither[E, L, B]) func(ReaderEither[E, L, A]) ReaderEither[E, L, B] { - return readert.Chain[ReaderEither[E, L, A], ReaderEither[E, L, B]](ET.Chain[L, A, B], f) + return readert.Chain[ReaderEither[E, L, A]](ET.Chain[L, A, B], f) } func Of[E, L, A any](a A) ReaderEither[E, L, A] { @@ -148,7 +148,7 @@ func BiMap[E, E1, E2, A, B any](f func(E1) E2, g func(A) B) func(ReaderEither[E, // Local changes the value of the local context during the execution of the action `ma` (similar to `Contravariant`'s // `contramap`). func Local[E, A, R2, R1 any](f func(R2) R1) func(ReaderEither[R1, E, A]) ReaderEither[R2, E, A] { - return reader.Local[Either[E, A], R2, R1](f) + return reader.Local[Either[E, A]](f) } // Read applies a context to a reader to obtain its value diff --git a/v2/readerio/bind.go b/v2/readerio/bind.go index f985e2a..2a19986 100644 --- a/v2/readerio/bind.go +++ b/v2/readerio/bind.go @@ -257,7 +257,7 @@ func BindL[R, S, T any]( lens L.Lens[S, T], f func(T) ReaderIO[R, T], ) func(ReaderIO[R, S]) ReaderIO[R, S] { - return Bind[R, S, S, T](lens.Set, F.Flow2(lens.Get, f)) + return Bind(lens.Set, F.Flow2(lens.Get, f)) } // LetL is a variant of Let that uses a lens to focus on a specific part of the context. @@ -290,7 +290,7 @@ func LetL[R, S, T any]( lens L.Lens[S, T], f func(T) T, ) func(ReaderIO[R, S]) ReaderIO[R, S] { - return Let[R, S, S, T](lens.Set, F.Flow2(lens.Get, f)) + return Let[R](lens.Set, F.Flow2(lens.Get, f)) } // LetToL is a variant of LetTo that uses a lens to focus on a specific part of the context. @@ -320,5 +320,5 @@ func LetToL[R, S, T any]( lens L.Lens[S, T], b T, ) func(ReaderIO[R, S]) ReaderIO[R, S] { - return LetTo[R, S, S, T](lens.Set, b) + return LetTo[R](lens.Set, b) } diff --git a/v2/readerio/generic/array.go b/v2/readerio/generic/array.go index c625b6f..598696e 100644 --- a/v2/readerio/generic/array.go +++ b/v2/readerio/generic/array.go @@ -22,7 +22,7 @@ import ( // MonadTraverseArray transforms an array func MonadTraverseArray[GB ~func(E) GIOB, GBS ~func(E) GIOBS, GIOB ~func() B, GIOBS ~func() BBS, AAS ~[]A, BBS ~[]B, E, A, B any](ma AAS, f func(A) GB) GBS { - return RA.MonadTraverse[AAS]( + return RA.MonadTraverse( Of[GBS, GIOBS, E, BBS], Map[GBS, func(E) func() func(B) BBS, GIOBS, func() func(B) BBS, E, BBS, func(B) BBS], Ap[GB, GBS, func(E) func() func(B) BBS, GIOB, GIOBS, func() func(B) BBS, E, B, BBS], diff --git a/v2/readerio/generic/reader.go b/v2/readerio/generic/reader.go index 325a893..d3c9abe 100644 --- a/v2/readerio/generic/reader.go +++ b/v2/readerio/generic/reader.go @@ -28,7 +28,7 @@ import ( ) func FromIO[GEA ~func(E) GIOA, GIOA ~func() A, E, A any](t GIOA) GEA { - return R.Of[GEA, E](t) + return R.Of[GEA](t) } func FromReader[GA ~func(E) A, GEA ~func(E) GIOA, GIOA ~func() A, E, A any](r GA) GEA { diff --git a/v2/readerioeither/bind.go b/v2/readerioeither/bind.go index 9197a3e..32d0e42 100644 --- a/v2/readerioeither/bind.go +++ b/v2/readerioeither/bind.go @@ -106,7 +106,7 @@ func Let[R, E, S1, S2, T any]( setter func(T) func(S1) S2, f func(S1) T, ) Operator[R, E, S1, S2] { - return G.Let[ReaderIOEither[R, E, S1], ReaderIOEither[R, E, S2], ioeither.IOEither[E, S1], ioeither.IOEither[E, S2], R, E, S1, S2, T](setter, f) + return G.Let[ReaderIOEither[R, E, S1], ReaderIOEither[R, E, S2]](setter, f) } // LetTo attaches the a value to a context [S1] to produce a context [S2] @@ -116,7 +116,7 @@ func LetTo[R, E, S1, S2, T any]( setter func(T) func(S1) S2, b T, ) Operator[R, E, S1, S2] { - return G.LetTo[ReaderIOEither[R, E, S1], ReaderIOEither[R, E, S2], ioeither.IOEither[E, S1], ioeither.IOEither[E, S2], R, E, S1, S2, T](setter, b) + return G.LetTo[ReaderIOEither[R, E, S1], ReaderIOEither[R, E, S2]](setter, b) } // BindTo initializes a new state [S1] from a value [T] @@ -125,7 +125,7 @@ func LetTo[R, E, S1, S2, T any]( func BindTo[R, E, S1, T any]( setter func(T) S1, ) Operator[R, E, T, S1] { - return G.BindTo[ReaderIOEither[R, E, S1], ReaderIOEither[R, E, T], ioeither.IOEither[E, S1], ioeither.IOEither[E, T], R, E, S1, T](setter) + return G.BindTo[ReaderIOEither[R, E, S1], ReaderIOEither[R, E, T]](setter) } // ApS attaches a value to a context [S1] to produce a context [S2] by considering @@ -175,7 +175,7 @@ func ApS[R, E, S1, S2, T any]( setter func(T) func(S1) S2, fa ReaderIOEither[R, E, T], ) Operator[R, E, S1, S2] { - return G.ApS[ReaderIOEither[R, E, func(T) S2], ReaderIOEither[R, E, S1], ReaderIOEither[R, E, S2], ReaderIOEither[R, E, T], ioeither.IOEither[E, func(T) S2], ioeither.IOEither[E, S1], ioeither.IOEither[E, S2], ioeither.IOEither[E, T], R, E, S1, S2, T](setter, fa) + return G.ApS[ReaderIOEither[R, E, func(T) S2], ReaderIOEither[R, E, S1], ReaderIOEither[R, E, S2]](setter, fa) } // ApSL attaches a value to a context using a lens-based setter. @@ -255,7 +255,7 @@ func BindL[R, E, S, T any]( lens L.Lens[S, T], f func(T) ReaderIOEither[R, E, T], ) Operator[R, E, S, S] { - return Bind[R, E, S, S, T](lens.Set, F.Flow2(lens.Get, f)) + return Bind(lens.Set, F.Flow2(lens.Get, f)) } // LetL is a variant of Let that uses a lens to focus on a specific part of the context. @@ -291,7 +291,7 @@ func LetL[R, E, S, T any]( lens L.Lens[S, T], f func(T) T, ) Operator[R, E, S, S] { - return Let[R, E, S, S, T](lens.Set, F.Flow2(lens.Get, f)) + return Let[R, E](lens.Set, F.Flow2(lens.Get, f)) } // LetToL is a variant of LetTo that uses a lens to focus on a specific part of the context. @@ -324,7 +324,7 @@ func LetToL[R, E, S, T any]( lens L.Lens[S, T], b T, ) Operator[R, E, S, S] { - return LetTo[R, E, S, S, T](lens.Set, b) + return LetTo[R, E](lens.Set, b) } // BindIOEitherK is a variant of Bind that works with IOEither computations. @@ -489,7 +489,7 @@ func ApReaderS[R, E, S1, S2, T any]( setter func(T) func(S1) S2, fa Reader[R, T], ) Operator[R, E, S1, S2] { - return ApS(setter, FromReader[E, R, T](fa)) + return ApS(setter, FromReader[E](fa)) } // ApReaderIOS is an applicative variant that works with ReaderIO values. @@ -502,7 +502,7 @@ func ApReaderIOS[R, E, S1, S2, T any]( setter func(T) func(S1) S2, fa ReaderIO[R, T], ) Operator[R, E, S1, S2] { - return ApS(setter, FromReaderIO[E, R, T](fa)) + return ApS(setter, FromReaderIO[E](fa)) } // ApEitherS is an applicative variant that works with Either values. @@ -515,7 +515,7 @@ func ApEitherS[R, E, S1, S2, T any]( setter func(T) func(S1) S2, fa Either[E, T], ) Operator[R, E, S1, S2] { - return ApS(setter, FromEither[R, E, T](fa)) + return ApS(setter, FromEither[R](fa)) } // ApIOEitherSL is a lens-based variant of ApIOEitherS. @@ -554,7 +554,7 @@ func ApReaderSL[R, E, S, T any]( lens L.Lens[S, T], fa Reader[R, T], ) Operator[R, E, S, S] { - return ApSL(lens, FromReader[E, R, T](fa)) + return ApSL(lens, FromReader[E](fa)) } // ApReaderIOSL is a lens-based variant of ApReaderIOS. @@ -567,7 +567,7 @@ func ApReaderIOSL[R, E, S, T any]( lens L.Lens[S, T], fa ReaderIO[R, T], ) Operator[R, E, S, S] { - return ApSL(lens, FromReaderIO[E, R, T](fa)) + return ApSL(lens, FromReaderIO[E](fa)) } // ApEitherSL is a lens-based variant of ApEitherS. @@ -580,5 +580,5 @@ func ApEitherSL[R, E, S, T any]( lens L.Lens[S, T], fa Either[E, T], ) Operator[R, E, S, S] { - return ApSL(lens, FromEither[R, E, T](fa)) + return ApSL(lens, FromEither[R](fa)) } diff --git a/v2/readerioeither/generic/bind.go b/v2/readerioeither/generic/bind.go index 4014dae..7143d5e 100644 --- a/v2/readerioeither/generic/bind.go +++ b/v2/readerioeither/generic/bind.go @@ -39,7 +39,7 @@ import ( func Do[GRS ~func(R) GS, GS ~func() either.Either[E, S], R, E, S any]( empty S, ) GRS { - return Of[GRS, GS, R, E, S](empty) + return Of[GRS](empty) } // Bind attaches the result of a computation to a context [S1] to produce a context [S2]. diff --git a/v2/readerioeither/generic/monad.go b/v2/readerioeither/generic/monad.go index 8e86a4b..e21870d 100644 --- a/v2/readerioeither/generic/monad.go +++ b/v2/readerioeither/generic/monad.go @@ -29,27 +29,27 @@ type readerIOEitherMonad[R, E, A, B any, GRA ~func(R) GIOA, GRB ~func(R) GIOB, G type readerIOEitherFunctor[R, E, A, B any, GRA ~func(R) GIOA, GRB ~func(R) GIOB, GIOA ~func() either.Either[E, A], GIOB ~func() either.Either[E, B]] struct{} func (o *readerIOEitherPointed[R, E, A, GRA, GIOA]) Of(a A) GRA { - return Of[GRA, GIOA, R, E, A](a) + return Of[GRA](a) } func (o *readerIOEitherMonad[R, E, A, B, GRA, GRB, GRAB, GIOA, GIOB, GIOAB]) Of(a A) GRA { - return Of[GRA, GIOA, R, E, A](a) + return Of[GRA](a) } func (o *readerIOEitherMonad[R, E, A, B, GRA, GRB, GRAB, GIOA, GIOB, GIOAB]) Map(f func(A) B) func(GRA) GRB { - return Map[GRA, GRB, GIOA, GIOB, R, E, A, B](f) + return Map[GRA, GRB](f) } func (o *readerIOEitherMonad[R, E, A, B, GRA, GRB, GRAB, GIOA, GIOB, GIOAB]) Chain(f func(A) GRB) func(GRA) GRB { - return Chain[GRA, GRB, GIOA, GIOB, R, E, A, B](f) + return Chain[GRA](f) } func (o *readerIOEitherMonad[R, E, A, B, GRA, GRB, GRAB, GIOA, GIOB, GIOAB]) Ap(fa GRA) func(GRAB) GRB { - return Ap[GRA, GRB, GRAB, GIOA, GIOB, GIOAB, R, E, A, B](fa) + return Ap[GRA, GRB, GRAB](fa) } func (o *readerIOEitherFunctor[R, E, A, B, GRA, GRB, GIOA, GIOB]) Map(f func(A) B) func(GRA) GRB { - return Map[GRA, GRB, GIOA, GIOB, R, E, A, B](f) + return Map[GRA, GRB](f) } // Pointed implements the pointed operations for [ReaderIOEither] diff --git a/v2/readerioeither/generic/reader.go b/v2/readerioeither/generic/reader.go index 4c3b5ed..eb66f2a 100644 --- a/v2/readerioeither/generic/reader.go +++ b/v2/readerioeither/generic/reader.go @@ -471,13 +471,13 @@ func BiMap[GA ~func(R) GE1A, GB ~func(R) GE2B, GE1A ~func() either.Either[E1, A] // Swap changes the order of type parameters // Deprecated: func Swap[GREA ~func(R) GEA, GRAE ~func(R) GAE, GEA ~func() either.Either[E, A], GAE ~func() either.Either[A, E], R, E, A any](val GREA) GRAE { - return RD.MonadMap[GREA, GRAE, R, GEA, GAE](val, IOE.Swap[GEA, GAE]) + return RD.MonadMap[GREA, GRAE](val, IOE.Swap[GEA, GAE]) } // Defer creates an IO by creating a brand new IO via a generator function, each time // Deprecated: func Defer[GEA ~func(R) GA, GA ~func() either.Either[E, A], R, E, A any](gen func() GEA) GEA { - return G.Defer[GEA](gen) + return G.Defer(gen) } // TryCatch wraps a reader returning a tuple as an error into ReaderIOEither @@ -494,7 +494,7 @@ func TryCatch[GEA ~func(R) GA, GA ~func() either.Either[E, A], R, E, A any](f fu // Deprecated: func Memoize[ GEA ~func(R) GIOA, GIOA ~func() either.Either[E, A], R, E, A any](rdr GEA) GEA { - return G.Memoize[GEA](rdr) + return G.Memoize(rdr) } // Deprecated: diff --git a/v2/readerioeither/generic/traverse.go b/v2/readerioeither/generic/traverse.go index 702432d..0e5e341 100644 --- a/v2/readerioeither/generic/traverse.go +++ b/v2/readerioeither/generic/traverse.go @@ -24,7 +24,7 @@ import ( // MonadTraverseArray transforms an array func MonadTraverseArray[GB ~func(E) GIOB, GBS ~func(E) GIOBS, GIOB ~func() either.Either[L, B], GIOBS ~func() either.Either[L, BBS], AAS ~[]A, BBS ~[]B, E, L, A, B any](ma AAS, f func(A) GB) GBS { - return RA.MonadTraverse[AAS]( + return RA.MonadTraverse( Of[GBS, GIOBS, E, L, BBS], Map[GBS, func(E) func() either.Either[L, func(B) BBS], GIOBS, func() either.Either[L, func(B) BBS], E, L, BBS, func(B) BBS], Ap[GB, GBS, func(E) func() either.Either[L, func(B) BBS], GIOB, GIOBS, func() either.Either[L, func(B) BBS], E, L, B, BBS], @@ -62,7 +62,7 @@ func SequenceArray[GA ~func(E) GIOA, GAS ~func(E) GIOAS, GIOA ~func() either.Eit // MonadTraverseRecord transforms an array func MonadTraverseRecord[GB ~func(C) GIOB, GBS ~func(C) GIOBS, GIOB ~func() either.Either[E, B], GIOBS ~func() either.Either[E, BBS], AAS ~map[K]A, BBS ~map[K]B, K comparable, C, E, A, B any](tas AAS, f func(A) GB) GBS { - return RR.MonadTraverse[AAS]( + return RR.MonadTraverse( Of[GBS, GIOBS, C, E, BBS], Map[GBS, func(C) func() either.Either[E, func(B) BBS], GIOBS, func() either.Either[E, func(B) BBS], C, E, BBS, func(B) BBS], Ap[GB, GBS, func(C) func() either.Either[E, func(B) BBS], GIOB, GIOBS, func() either.Either[E, func(B) BBS], C, E, B, BBS], diff --git a/v2/readerioeither/reader.go b/v2/readerioeither/reader.go index 136a5dc..2d33eaf 100644 --- a/v2/readerioeither/reader.go +++ b/v2/readerioeither/reader.go @@ -614,5 +614,5 @@ func MapLeft[R, A, E1, E2 any](f func(E1) E2) func(ReaderIOEither[R, E1, A]) Rea // //go:inline func Local[E, A, R1, R2 any](f func(R2) R1) func(ReaderIOEither[R1, E, A]) ReaderIOEither[R2, E, A] { - return reader.Local[IOEither[E, A], R2, R1](f) + return reader.Local[IOEither[E, A]](f) } diff --git a/v2/readerioeither/readerioeither_test.go b/v2/readerioeither/readerioeither_test.go index 750b819..4be50a2 100644 --- a/v2/readerioeither/readerioeither_test.go +++ b/v2/readerioeither/readerioeither_test.go @@ -193,7 +193,7 @@ func TestChainOptionK(t *testing.T) { // Test with Some resultSome := F.Pipe1( Of[testContext, error](5), - ChainOptionK[testContext, int, int, error](func() error { + ChainOptionK[testContext, int, int](func() error { return errors.New("none") })(func(x int) O.Option[int] { return O.Some(x * 2) @@ -204,7 +204,7 @@ func TestChainOptionK(t *testing.T) { // Test with None resultNone := F.Pipe1( Of[testContext, error](5), - ChainOptionK[testContext, int, int, error](func() error { + ChainOptionK[testContext, int, int](func() error { return errors.New("none") })(func(x int) O.Option[int] { return O.None[int]() @@ -233,7 +233,7 @@ func TestChain(t *testing.T) { ctx := testContext{value: 10} result := F.Pipe1( Of[testContext, error](5), - Chain[testContext, error](func(x int) ReaderIOEither[testContext, error, int] { + Chain(func(x int) ReaderIOEither[testContext, error, int] { return Of[testContext, error](x * 2) }), ) @@ -340,14 +340,14 @@ func TestFromPredicate(t *testing.T) { ctx := testContext{value: 10} // Test predicate true - resultTrue := FromPredicate[testContext, error]( + resultTrue := FromPredicate[testContext]( func(x int) bool { return x > 0 }, func(x int) error { return errors.New("negative") }, )(5) assert.Equal(t, E.Right[error](5), resultTrue(ctx)()) // Test predicate false - resultFalse := FromPredicate[testContext, error]( + resultFalse := FromPredicate[testContext]( func(x int) bool { return x > 0 }, func(x int) error { return errors.New("negative") }, )(-5) @@ -369,7 +369,7 @@ func TestFold(t *testing.T) { assert.Equal(t, "value: 42", resultRight(ctx)()) // Test Left case - resultLeft := Fold[testContext, error, int, string]( + resultLeft := Fold( func(e error) RIO.ReaderIO[testContext, string] { return RIO.Of[testContext]("error: " + e.Error()) }, @@ -384,13 +384,13 @@ func TestGetOrElse(t *testing.T) { ctx := testContext{value: 10} // Test Right case - resultRight := GetOrElse[testContext, error](func(e error) RIO.ReaderIO[testContext, int] { + resultRight := GetOrElse(func(e error) RIO.ReaderIO[testContext, int] { return RIO.Of[testContext](0) })(Of[testContext, error](42)) assert.Equal(t, 42, resultRight(ctx)()) // Test Left case - resultLeft := GetOrElse[testContext, error](func(e error) RIO.ReaderIO[testContext, int] { + resultLeft := GetOrElse(func(e error) RIO.ReaderIO[testContext, int] { return RIO.Of[testContext](0) })(Left[testContext, int](errors.New("test"))) assert.Equal(t, 0, resultLeft(ctx)()) @@ -400,13 +400,13 @@ func TestOrElse(t *testing.T) { ctx := testContext{value: 10} // Test Right case - resultRight := OrElse[testContext, error, int, string](func(e error) ReaderIOEither[testContext, string, int] { + resultRight := OrElse(func(e error) ReaderIOEither[testContext, string, int] { return Left[testContext, int]("alternative") })(Of[testContext, error](42)) assert.Equal(t, E.Right[string](42), resultRight(ctx)()) // Test Left case - resultLeft := OrElse[testContext, error, int, string](func(e error) ReaderIOEither[testContext, string, int] { + resultLeft := OrElse(func(e error) ReaderIOEither[testContext, string, int] { return Of[testContext, string](99) })(Left[testContext, int](errors.New("test"))) assert.Equal(t, E.Right[string](99), resultLeft(ctx)()) @@ -436,7 +436,7 @@ func TestBiMap(t *testing.T) { ctx := testContext{value: 10} result := F.Pipe1( Of[testContext, error](5), - BiMap[testContext, error, string]( + BiMap[testContext]( error.Error, strconv.Itoa, ), @@ -522,7 +522,7 @@ func TestAlt(t *testing.T) { ctx := testContext{value: 10} result := F.Pipe1( Left[testContext, int](errors.New("first")), - Alt[testContext, error](func() ReaderIOEither[testContext, error, int] { + Alt(func() ReaderIOEither[testContext, error, int] { return Of[testContext, error](99) }), ) @@ -616,7 +616,7 @@ func TestRightReaderIO(t *testing.T) { rio := func(c testContext) io.IO[int] { return func() int { return c.value * 2 } } - result := RightReaderIO[error, testContext](rio) + result := RightReaderIO[error](rio) assert.Equal(t, E.Right[error](20), result(ctx)()) } @@ -703,7 +703,7 @@ func TestWithResource(t *testing.T) { ctx := testContext{value: 10} released := false - result := WithResource[string, testContext, error, int, int]( + result := WithResource[string]( Of[testContext, error](42), func(x int) ReaderIOEither[testContext, error, int] { released = true @@ -724,7 +724,7 @@ func TestMonad(t *testing.T) { func TestTraverseArrayWithIndex(t *testing.T) { ctx := testContext{value: 10} - result := TraverseArrayWithIndex[testContext, error](func(i int, x int) ReaderIOEither[testContext, error, int] { + result := TraverseArrayWithIndex(func(i int, x int) ReaderIOEither[testContext, error, int] { return Of[testContext, error](x + i) })([]int{1, 2, 3}) @@ -733,7 +733,7 @@ func TestTraverseArrayWithIndex(t *testing.T) { func TestTraverseRecord(t *testing.T) { ctx := testContext{value: 10} - result := TraverseRecord[string, testContext, error](func(x int) ReaderIOEither[testContext, error, int] { + result := TraverseRecord[string](func(x int) ReaderIOEither[testContext, error, int] { return Of[testContext, error](x * 2) })(map[string]int{"a": 1, "b": 2}) diff --git a/v2/readerioresult/bind.go b/v2/readerioresult/bind.go index c12589d..dac85db 100644 --- a/v2/readerioresult/bind.go +++ b/v2/readerioresult/bind.go @@ -654,7 +654,7 @@ func ApReaderS[R, S1, S2, T any]( setter func(T) func(S1) S2, fa Reader[R, T], ) Operator[R, S1, S2] { - return ApS(setter, FromReader[R, T](fa)) + return ApS(setter, FromReader(fa)) } // ApReaderIOS is an applicative variant that works with ReaderIO values. @@ -667,7 +667,7 @@ func ApReaderIOS[R, S1, S2, T any]( setter func(T) func(S1) S2, fa ReaderIO[R, T], ) Operator[R, S1, S2] { - return ApS(setter, FromReaderIO[R, T](fa)) + return ApS(setter, FromReaderIO(fa)) } // ApEitherS is an applicative variant that works with Either (Result) values. @@ -686,7 +686,7 @@ func ApEitherS[R, S1, S2, T any]( setter func(T) func(S1) S2, fa Result[T], ) Operator[R, S1, S2] { - return ApS(setter, FromEither[R, T](fa)) + return ApS(setter, FromEither[R](fa)) } // ApResultS is an applicative variant that works with Result values. @@ -699,7 +699,7 @@ func ApResultS[R, S1, S2, T any]( setter func(T) func(S1) S2, fa Result[T], ) Operator[R, S1, S2] { - return ApS(setter, FromResult[R, T](fa)) + return ApS(setter, FromResult[R](fa)) } // ApIOEitherSL is a lens-based variant of ApIOEitherS. @@ -777,7 +777,7 @@ func ApReaderSL[R, S, T any]( lens L.Lens[S, T], fa Reader[R, T], ) Operator[R, S, S] { - return ApSL(lens, FromReader[R, T](fa)) + return ApSL(lens, FromReader(fa)) } // ApReaderIOSL is a lens-based variant of ApReaderIOS. @@ -803,7 +803,7 @@ func ApReaderIOSL[R, S, T any]( lens L.Lens[S, T], fa ReaderIO[R, T], ) Operator[R, S, S] { - return ApSL(lens, FromReaderIO[R, T](fa)) + return ApSL(lens, FromReaderIO(fa)) } // ApEitherSL is a lens-based variant of ApEitherS. @@ -826,7 +826,7 @@ func ApEitherSL[R, S, T any]( lens L.Lens[S, T], fa Result[T], ) Operator[R, S, S] { - return ApSL(lens, FromEither[R, T](fa)) + return ApSL(lens, FromEither[R](fa)) } // ApResultSL is a lens-based variant of ApResultS. @@ -839,5 +839,5 @@ func ApResultSL[R, S, T any]( lens L.Lens[S, T], fa Result[T], ) Operator[R, S, S] { - return ApSL(lens, FromResult[R, T](fa)) + return ApSL(lens, FromResult[R](fa)) } diff --git a/v2/readerioresult/monoid.go b/v2/readerioresult/monoid.go index 53a2f0d..fd21f81 100644 --- a/v2/readerioresult/monoid.go +++ b/v2/readerioresult/monoid.go @@ -82,5 +82,5 @@ func AlternativeMonoid[R, A any](m monoid.Monoid[A]) Monoid[R, A] { // // Returns a Monoid for ReaderIOResult[A] with Alt-based combination. func AltMonoid[R, A any](zero lazy.Lazy[ReaderIOResult[R, A]]) Monoid[R, A] { - return RIOE.AltMonoid[R, error](zero) + return RIOE.AltMonoid(zero) } diff --git a/v2/readerioresult/reader.go b/v2/readerioresult/reader.go index 9f58bdc..f10bcc8 100644 --- a/v2/readerioresult/reader.go +++ b/v2/readerioresult/reader.go @@ -23,14 +23,14 @@ import ( // FromReaderIO creates a function that lifts a ReaderIO-producing function into ReaderIOResult. // The ReaderIO result is placed in the Right side of the Either. func FromReaderIO[R, A any](ma ReaderIO[R, A]) ReaderIOResult[R, A] { - return RIOE.FromReaderIO[error, R](ma) + return RIOE.FromReaderIO[error](ma) } // RightReaderIO lifts a ReaderIO into a ReaderIOResult, placing the result in the Right side. // //go:inline func RightReaderIO[R, A any](ma ReaderIO[R, A]) ReaderIOResult[R, A] { - return RIOE.RightReaderIO[error, R](ma) + return RIOE.RightReaderIO[error](ma) } // LeftReaderIO lifts a ReaderIO into a ReaderIOResult, placing the result in the Left (error) side. diff --git a/v2/record/bind.go b/v2/record/bind.go index 67149ad..67568b0 100644 --- a/v2/record/bind.go +++ b/v2/record/bind.go @@ -31,7 +31,7 @@ import ( // } // result := record.Do[string, State]() func Do[K comparable, S any]() map[K]S { - return G.Do[map[K]S, K, S]() + return G.Do[map[K]S]() } // Bind attaches the result of a computation to a context [S1] to produce a context [S2]. @@ -69,7 +69,7 @@ func Do[K comparable, S any]() map[K]S { // ), // ) func Bind[S1, T any, K comparable, S2 any](m Mo.Monoid[map[K]S2]) func(setter func(T) func(S1) S2, f func(S1) map[K]T) func(map[K]S1) map[K]S2 { - return G.Bind[map[K]S1, map[K]S2, map[K]T, K, S1, S2, T](m) + return G.Bind[map[K]S1, map[K]S2, map[K]T](m) } // Let attaches the result of a computation to a context [S1] to produce a context [S2] @@ -77,7 +77,7 @@ func Let[S1, T any, K comparable, S2 any]( setter func(T) func(S1) S2, f func(S1) T, ) func(map[K]S1) map[K]S2 { - return G.Let[map[K]S1, map[K]S2, K, S1, S2, T](setter, f) + return G.Let[map[K]S1, map[K]S2](setter, f) } // LetTo attaches the a value to a context [S1] to produce a context [S2] @@ -85,12 +85,12 @@ func LetTo[S1, T any, K comparable, S2 any]( setter func(T) func(S1) S2, b T, ) func(map[K]S1) map[K]S2 { - return G.LetTo[map[K]S1, map[K]S2, K, S1, S2, T](setter, b) + return G.LetTo[map[K]S1, map[K]S2](setter, b) } // BindTo initializes a new state [S1] from a value [T] func BindTo[S1, T any, K comparable](setter func(T) S1) func(map[K]T) map[K]S1 { - return G.BindTo[map[K]S1, map[K]T, K, S1, T](setter) + return G.BindTo[map[K]S1, map[K]T](setter) } // ApS attaches a value to a context [S1] to produce a context [S2] by considering @@ -127,5 +127,5 @@ func BindTo[S1, T any, K comparable](setter func(T) S1) func(map[K]T) map[K]S1 { // ), // ) // map[string]State{"a": {Name: "Alice", Count: 10}, "b": {Name: "Bob", Count: 20}} func ApS[S1, T any, K comparable, S2 any](m Mo.Monoid[map[K]S2]) func(setter func(T) func(S1) S2, fa map[K]T) func(map[K]S1) map[K]S2 { - return G.ApS[map[K]S1, map[K]S2, map[K]T, K, S1, S2, T](m) + return G.ApS[map[K]S1, map[K]S2, map[K]T](m) } diff --git a/v2/record/eq.go b/v2/record/eq.go index b57d021..65c9373 100644 --- a/v2/record/eq.go +++ b/v2/record/eq.go @@ -21,7 +21,7 @@ import ( ) func Eq[K comparable, V any](e E.Eq[V]) E.Eq[map[K]V] { - return G.Eq[map[K]V, K, V](e) + return G.Eq[map[K]V](e) } // FromStrictEquals constructs an [EQ.Eq] from the canonical comparison function diff --git a/v2/record/generic/bind.go b/v2/record/generic/bind.go index 4b8a933..94e814e 100644 --- a/v2/record/generic/bind.go +++ b/v2/record/generic/bind.go @@ -33,7 +33,7 @@ import ( // } // result := generic.Do[map[string]State, string, State]() func Do[GS ~map[K]S, K comparable, S any]() GS { - return Empty[GS, K, S]() + return Empty[GS]() } // Bind attaches the result of a computation to a context [S1] to produce a context [S2]. @@ -75,7 +75,7 @@ func Do[GS ~map[K]S, K comparable, S any]() GS { // ), // ) func Bind[GS1 ~map[K]S1, GS2 ~map[K]S2, GT ~map[K]T, K comparable, S1, S2, T any](m Mo.Monoid[GS2]) func(setter func(T) func(S1) S2, f func(S1) GT) func(GS1) GS2 { - c := Chain[GS1, GS2, K, S1, S2](m) + c := Chain[GS1](m) return func(setter func(T) func(S1) S2, f func(S1) GT) func(GS1) GS2 { return C.Bind( c, @@ -156,7 +156,7 @@ func BindTo[GS1 ~map[K]S1, GT ~map[K]T, K comparable, S1, T any](setter func(T) // ), // ) // map[string]State{"player1": {Name: "Alice", Score: 100}, "player2": {Name: "Bob", Score: 200}} func ApS[GS1 ~map[K]S1, GS2 ~map[K]S2, GT ~map[K]T, K comparable, S1, S2, T any](m Mo.Monoid[GS2]) func(setter func(T) func(S1) S2, fa GT) func(GS1) GS2 { - a := Ap[GS2, map[K]func(T) S2, GT, K, S2, T](m) + a := Ap[GS2, map[K]func(T) S2, GT](m) return func(setter func(T) func(S1) S2, fa GT) func(GS1) GS2 { return A.ApS( a, diff --git a/v2/record/generic/record.go b/v2/record/generic/record.go index 993ae99..c37e8e4 100644 --- a/v2/record/generic/record.go +++ b/v2/record/generic/record.go @@ -382,7 +382,7 @@ func FromFoldable[ M ~map[K]V, K comparable, V any](m Mg.Magma[V], red FOLDABLE) func(fa HKTA) M { - return FromFoldableMap[func(T.Tuple2[K, V]) T.Tuple2[K, V], HKTA, FOLDABLE](m, red)(F.Identity[T.Tuple2[K, V]]) + return FromFoldableMap[func(T.Tuple2[K, V]) T.Tuple2[K, V]](m, red)(F.Identity[T.Tuple2[K, V]]) } func FromArrayMap[ @@ -400,7 +400,7 @@ func FromArray[ M ~map[K]V, K comparable, V any](m Mg.Magma[V]) func(fa GA) M { - return FromFoldable[GA](m, F.Bind23of3(RAG.Reduce[GA, T.Tuple2[K, V], M])) + return FromFoldable(m, F.Bind23of3(RAG.Reduce[GA, T.Tuple2[K, V], M])) } func FromEntries[M ~map[K]V, GT ~[]T.Tuple2[K, V], K comparable, V any](fa GT) M { @@ -489,12 +489,12 @@ func FilterMap[M ~map[K]V1, N ~map[K]V2, K comparable, V1, V2 any](f func(V1) O. // Flatten converts a nested map into a regular map func Flatten[M ~map[K]N, N ~map[K]V, K comparable, V any](m Mo.Monoid[N]) func(M) N { - return Chain[M, N](m)(F.Identity[N]) + return Chain[M](m)(F.Identity[N]) } // FilterChainWithIndex creates a new map with only the elements for which the transformation function creates a Some func FilterChainWithIndex[M ~map[K]V1, N ~map[K]V2, K comparable, V1, V2 any](m Mo.Monoid[N]) func(func(K, V1) O.Option[N]) func(M) N { - flatten := Flatten[map[K]N, N](m) + flatten := Flatten[map[K]N](m) return func(f func(K, V1) O.Option[N]) func(M) N { return F.Flow2( FilterMapWithIndex[M, map[K]N](f), @@ -505,7 +505,7 @@ func FilterChainWithIndex[M ~map[K]V1, N ~map[K]V2, K comparable, V1, V2 any](m // FilterChain creates a new map with only the elements for which the transformation function creates a Some func FilterChain[M ~map[K]V1, N ~map[K]V2, K comparable, V1, V2 any](m Mo.Monoid[N]) func(func(V1) O.Option[N]) func(M) N { - flatten := Flatten[map[K]N, N](m) + flatten := Flatten[map[K]N](m) return func(f func(V1) O.Option[N]) func(M) N { return F.Flow2( FilterMap[M, map[K]N](f), diff --git a/v2/record/generic/semigroup.go b/v2/record/generic/semigroup.go index c64cea2..adac3f9 100644 --- a/v2/record/generic/semigroup.go +++ b/v2/record/generic/semigroup.go @@ -21,18 +21,18 @@ import ( func UnionSemigroup[N ~map[K]V, K comparable, V any](s S.Semigroup[V]) S.Semigroup[N] { return S.MakeSemigroup(func(first N, second N) N { - return union[N, K, V](S.ToMagma(s), first, second) + return union(S.ToMagma(s), first, second) }) } func UnionLastSemigroup[N ~map[K]V, K comparable, V any]() S.Semigroup[N] { return S.MakeSemigroup(func(first N, second N) N { - return unionLast[N, K, V](first, second) + return unionLast(first, second) }) } func UnionFirstSemigroup[N ~map[K]V, K comparable, V any]() S.Semigroup[N] { return S.MakeSemigroup(func(first N, second N) N { - return unionLast[N, K, V](second, first) + return unionLast(second, first) }) } diff --git a/v2/record/record.go b/v2/record/record.go index 860a797..590f4fe 100644 --- a/v2/record/record.go +++ b/v2/record/record.go @@ -110,7 +110,7 @@ func Lookup[V any, K comparable](k K) func(map[K]V) O.Option[V] { // MonadLookup returns the entry for a key in a map if it exists func MonadLookup[V any, K comparable](m map[K]V, k K) O.Option[V] { - return G.MonadLookup[map[K]V](m, k) + return G.MonadLookup(m, k) } // Has tests if a key is contained in a map @@ -124,7 +124,7 @@ func Union[K comparable, V any](m Mg.Magma[V]) func(map[K]V) func(map[K]V) map[K // Merge combines two maps giving the values in the right one precedence. Also refer to [MergeMonoid] func Merge[K comparable, V any](right map[K]V) func(map[K]V) map[K]V { - return G.Merge[map[K]V](right) + return G.Merge(right) } // Empty creates an empty map @@ -260,7 +260,7 @@ func FoldMapOrd[A, B any, K comparable](o ord.Ord[K]) func(m Mo.Monoid[B]) func( // Fold folds the record using the provided Monoid with the items passed in the given order func FoldOrd[A any, K comparable](o ord.Ord[K]) func(m Mo.Monoid[A]) func(map[K]A) A { - return G.FoldOrd[map[K]A, K, A](o) + return G.FoldOrd[map[K]A](o) } // FoldMapWithIndex maps and folds a record. Map the record passing each value to the iterating function. Then fold the results using the provided Monoid and the items in the provided order @@ -270,12 +270,12 @@ func FoldMapOrdWithIndex[K comparable, A, B any](o ord.Ord[K]) func(m Mo.Monoid[ // KeysOrd returns the keys in the map in their given order func KeysOrd[V any, K comparable](o ord.Ord[K]) func(r map[K]V) []K { - return G.KeysOrd[map[K]V, []K, K, V](o) + return G.KeysOrd[map[K]V, []K](o) } // ValuesOrd returns the values in the map ordered by their keys in the given order func ValuesOrd[V any, K comparable](o ord.Ord[K]) func(r map[K]V) []V { - return G.ValuesOrd[map[K]V, []V, K, V](o) + return G.ValuesOrd[map[K]V, []V](o) } func MonadFlap[B any, K comparable, A any](fab map[K]func(A) B, a A) map[K]B { @@ -288,7 +288,7 @@ func Flap[B any, K comparable, A any](a A) func(map[K]func(A) B) map[K]B { // Copy creates a shallow copy of the map func Copy[K comparable, V any](m map[K]V) map[K]V { - return G.Copy[map[K]V](m) + return G.Copy(m) } // Clone creates a deep copy of the map using the provided endomorphism to clone the values @@ -323,7 +323,7 @@ func FromFoldable[ FOLDABLE ~func(func(map[K]V, T.Tuple2[K, V]) map[K]V, map[K]V) func(HKTA) map[K]V, // the reduce function K comparable, V any](m Mg.Magma[V], red FOLDABLE) func(fa HKTA) map[K]V { - return G.FromFoldable[HKTA, FOLDABLE](m, red) + return G.FromFoldable(m, red) } // FromArray converts from an array to a map @@ -335,7 +335,7 @@ func FromArray[ } func MonadAp[A any, K comparable, B any](m Mo.Monoid[map[K]B], fab map[K]func(A) B, fa map[K]A) map[K]B { - return G.MonadAp[map[K]B, map[K]func(A) B, map[K]A](m, fab, fa) + return G.MonadAp(m, fab, fa) } func Ap[A any, K comparable, B any](m Mo.Monoid[map[K]B]) func(fa map[K]A) func(map[K]func(A) B) map[K]B { diff --git a/v2/result/resource.go b/v2/result/resource.go index 32b48e1..981b319 100644 --- a/v2/result/resource.go +++ b/v2/result/resource.go @@ -44,5 +44,5 @@ import ( // return either.Right[error]("data") // }) func WithResource[R, A, ANY any](onCreate func() Result[R], onRelease Kleisli[R, ANY]) Kleisli[Kleisli[R, A], A] { - return either.WithResource[error, R, A, ANY](onCreate, onRelease) + return either.WithResource[error, R, A](onCreate, onRelease) } diff --git a/v2/samples/presentation/benchmarks/map_test.go b/v2/samples/presentation/benchmarks/map_test.go index 0234ab9..fbd07ef 100644 --- a/v2/samples/presentation/benchmarks/map_test.go +++ b/v2/samples/presentation/benchmarks/map_test.go @@ -79,7 +79,7 @@ func BenchmarkMapThenFilter(b *testing.B) { benchResult = F.Pipe2( data, A.Filter(isPrime), - A.Map(N.Div[int](2)), + A.Map(N.Div(2)), ) } }) @@ -100,7 +100,7 @@ func BenchmarkMapThenFilter(b *testing.B) { benchResult = F.Pipe2( data, A.Filter(isEven), - A.Map(N.Div[int](2)), + A.Map(N.Div(2)), ) } }) @@ -131,7 +131,7 @@ func BenchmarkFilterMap(b *testing.B) { data, A.FilterMap(F.Flow2( O.FromPredicate(isPrime), - O.Map(N.Div[int](2)), + O.Map(N.Div(2)), )), ) } @@ -155,7 +155,7 @@ func BenchmarkFilterMap(b *testing.B) { data, A.FilterMap(F.Flow2( O.FromPredicate(isEven), - O.Map(N.Div[int](2)), + O.Map(N.Div(2)), )), ) } diff --git a/v2/semigroup/semigroup.go b/v2/semigroup/semigroup.go index 882f1ae..79861bb 100644 --- a/v2/semigroup/semigroup.go +++ b/v2/semigroup/semigroup.go @@ -38,7 +38,7 @@ func MakeSemigroup[A any](c func(A, A) A) Semigroup[A] { // Reverse returns The dual of a `Semigroup`, obtained by swapping the arguments of `concat`. func Reverse[A any](m Semigroup[A]) Semigroup[A] { - return MakeSemigroup(M.Reverse[A](m).Concat) + return MakeSemigroup(M.Reverse(m).Concat) } // FunctionSemigroup forms a semigroup as long as you can provide a semigroup for the codomain. diff --git a/v2/semigroup/semigroup_test.go b/v2/semigroup/semigroup_test.go index 9f5b481..f8fb945 100644 --- a/v2/semigroup/semigroup_test.go +++ b/v2/semigroup/semigroup_test.go @@ -215,7 +215,7 @@ func TestApplySemigroup(t *testing.T) { return result } - applySG := ApplySemigroup[int, HKT, []func(int) int](fmap, fap, add) + applySG := ApplySemigroup(fmap, fap, add) hkt1 := HKT{1, 2} hkt2 := HKT{3, 4} @@ -240,7 +240,7 @@ func TestAltSemigroup(t *testing.T) { return second() } - altSG := AltSemigroup[Option[int], func() Option[int]](falt) + altSG := AltSemigroup(falt) some := Option[int]{value: 42, hasValue: true} none := Option[int]{hasValue: false} diff --git a/v2/state/testing/laws_test.go b/v2/state/testing/laws_test.go index 32dbd51..95160e2 100644 --- a/v2/state/testing/laws_test.go +++ b/v2/state/testing/laws_test.go @@ -26,7 +26,7 @@ import ( func TestMonadLaws(t *testing.T) { // some comparison - eqs := A.Eq[string](EQ.FromStrictEquals[string]()) + eqs := A.Eq(EQ.FromStrictEquals[string]()) eqa := EQ.FromStrictEquals[bool]() eqb := EQ.FromStrictEquals[int]() eqc := EQ.FromStrictEquals[string]() diff --git a/v2/tuple/tuple_test.go b/v2/tuple/tuple_test.go index 3e10f01..ef5a941 100644 --- a/v2/tuple/tuple_test.go +++ b/v2/tuple/tuple_test.go @@ -219,21 +219,21 @@ func TestToArray3FromArray3(t *testing.T) { // Test Push functions func TestPush1(t *testing.T) { t1 := MakeTuple1(42) - push := Push1[int, string]("hello") + push := Push1[int]("hello") result := push(t1) assert.Equal(t, MakeTuple2(42, "hello"), result) } func TestPush2(t *testing.T) { t2 := MakeTuple2(1, 2) - push := Push2[int, int, int](3) + push := Push2[int, int](3) result := push(t2) assert.Equal(t, MakeTuple3(1, 2, 3), result) } func TestPush3(t *testing.T) { t3 := MakeTuple3(1, 2, 3) - push := Push3[int, int, int, int](4) + push := Push3[int, int, int](4) result := push(t3) assert.Equal(t, MakeTuple4(1, 2, 3, 4), result) } @@ -511,14 +511,14 @@ func TestToArray5FromArray5(t *testing.T) { // Test Push for larger tuples func TestPush4(t *testing.T) { t4 := MakeTuple4(1, 2, 3, 4) - push := Push4[int, int, int, int, int](5) + push := Push4[int, int, int, int](5) result := push(t4) assert.Equal(t, MakeTuple5(1, 2, 3, 4, 5), result) } func TestPush5(t *testing.T) { t5 := MakeTuple5(1, 2, 3, 4, 5) - push := Push5[int, int, int, int, int, int](6) + push := Push5[int, int, int, int, int](6) result := push(t5) assert.Equal(t, MakeTuple6(1, 2, 3, 4, 5, 6), result) } @@ -927,28 +927,28 @@ func TestToArray10FromArray10(t *testing.T) { // Test Push for sizes 6-10 func TestPush6(t *testing.T) { t6 := MakeTuple6(1, 2, 3, 4, 5, 6) - push := Push6[int, int, int, int, int, int, int](7) + push := Push6[int, int, int, int, int, int](7) result := push(t6) assert.Equal(t, MakeTuple7(1, 2, 3, 4, 5, 6, 7), result) } func TestPush7(t *testing.T) { t7 := MakeTuple7(1, 2, 3, 4, 5, 6, 7) - push := Push7[int, int, int, int, int, int, int, int](8) + push := Push7[int, int, int, int, int, int, int](8) result := push(t7) assert.Equal(t, MakeTuple8(1, 2, 3, 4, 5, 6, 7, 8), result) } func TestPush8(t *testing.T) { t8 := MakeTuple8(1, 2, 3, 4, 5, 6, 7, 8) - push := Push8[int, int, int, int, int, int, int, int, int](9) + push := Push8[int, int, int, int, int, int, int, int](9) result := push(t8) assert.Equal(t, MakeTuple9(1, 2, 3, 4, 5, 6, 7, 8, 9), result) } func TestPush9(t *testing.T) { t9 := MakeTuple9(1, 2, 3, 4, 5, 6, 7, 8, 9) - push := Push9[int, int, int, int, int, int, int, int, int, int](10) + push := Push9[int, int, int, int, int, int, int, int, int](10) result := push(t9) assert.Equal(t, MakeTuple10(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), result) } @@ -1660,35 +1660,35 @@ func TestToArray15FromArray15(t *testing.T) { // Test Push for sizes 10-14 func TestPush10(t *testing.T) { t10 := MakeTuple10(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) - push := Push10[int, int, int, int, int, int, int, int, int, int, int](11) + push := Push10[int, int, int, int, int, int, int, int, int, int](11) result := push(t10) assert.Equal(t, MakeTuple11(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11), result) } func TestPush11(t *testing.T) { t11 := MakeTuple11(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) - push := Push11[int, int, int, int, int, int, int, int, int, int, int, int](12) + push := Push11[int, int, int, int, int, int, int, int, int, int, int](12) result := push(t11) assert.Equal(t, MakeTuple12(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), result) } func TestPush12(t *testing.T) { t12 := MakeTuple12(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) - push := Push12[int, int, int, int, int, int, int, int, int, int, int, int, int](13) + push := Push12[int, int, int, int, int, int, int, int, int, int, int, int](13) result := push(t12) assert.Equal(t, MakeTuple13(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13), result) } func TestPush13(t *testing.T) { t13 := MakeTuple13(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13) - push := Push13[int, int, int, int, int, int, int, int, int, int, int, int, int, int](14) + push := Push13[int, int, int, int, int, int, int, int, int, int, int, int, int](14) result := push(t13) assert.Equal(t, MakeTuple14(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14), result) } func TestPush14(t *testing.T) { t14 := MakeTuple14(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14) - push := Push14[int, int, int, int, int, int, int, int, int, int, int, int, int, int, int](15) + push := Push14[int, int, int, int, int, int, int, int, int, int, int, int, int, int](15) result := push(t14) assert.Equal(t, MakeTuple15(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15), result) }