1
0
mirror of https://github.com/IBM/fp-go.git synced 2025-11-25 22:21:49 +02:00

fix: add auto generation for Eitherize

Signed-off-by: Dr. Carsten Leue <carsten.leue@de.ibm.com>
This commit is contained in:
Dr. Carsten Leue
2023-07-13 16:14:38 +02:00
parent 288422ecf1
commit b34f3e3ae1
20 changed files with 2200 additions and 1270 deletions

13
cli/commands.go Normal file
View File

@@ -0,0 +1,13 @@
package cli
import (
C "github.com/urfave/cli/v2"
)
func Commands() []*C.Command {
return []*C.Command{
PipeCommand(),
OptionCommand(),
EitherCommand(),
}
}

24
cli/common.go Normal file
View File

@@ -0,0 +1,24 @@
package cli
import (
C "github.com/urfave/cli/v2"
)
const (
keyFilename = "filename"
keyCount = "count"
)
var (
flagFilename = &C.StringFlag{
Name: keyFilename,
Value: "gen.go",
Usage: "Name of the generated file",
}
flagCount = &C.IntFlag{
Name: keyCount,
Value: 20,
Usage: "Number of variations to create",
}
)

156
cli/either.go Normal file
View File

@@ -0,0 +1,156 @@
package cli
import (
"fmt"
"log"
"os"
"path/filepath"
"time"
C "github.com/urfave/cli/v2"
)
func generateUneitherize(f *os.File, i int) {
// Create the optionize version
fmt.Fprintf(f, "\n// Uneitherize%d converts a function with %d parameters returning an Either into a function with %d parameters returning a tuple\n", i, i, i)
fmt.Fprintf(f, "func Uneitherize%d[F ~func(", i)
for j := 0; j < i; j++ {
if j > 0 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "T%d", j)
}
fmt.Fprintf(f, ") Either[error, R]")
for j := 0; j < i; j++ {
fmt.Fprintf(f, ", T%d", j)
}
fmt.Fprintf(f, ", R any](f F) func(")
for j := 0; j < i; j++ {
if j > 0 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "T%d", j)
}
fmt.Fprintf(f, ") (R, error) {\n")
fmt.Fprintf(f, " return func(")
for j := 0; j < i; j++ {
if j > 0 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "t%d T%d", j, j)
}
fmt.Fprintf(f, ") (R, error) {\n")
fmt.Fprintf(f, " return UnwrapError(f(")
for j := 0; j < i; j++ {
if j > 0 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "t%d", j)
}
fmt.Fprintln(f, "))")
fmt.Fprintln(f, " }")
fmt.Fprintln(f, "}")
}
func generateEitherize(f *os.File, i int) {
// Create the optionize version
fmt.Fprintf(f, "\n// Eitherize%d converts a function with %d parameters returning a tuple into a function with %d parameters returning an Either\n", i, i, i)
fmt.Fprintf(f, "func Eitherize%d[F ~func(", i)
for j := 0; j < i; j++ {
if j > 0 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "T%d", j)
}
fmt.Fprintf(f, ") (R, error)")
for j := 0; j < i; j++ {
fmt.Fprintf(f, ", T%d", j)
}
fmt.Fprintf(f, ", R any](f F) func(")
for j := 0; j < i; j++ {
if j > 0 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "T%d", j)
}
fmt.Fprintf(f, ") Either[error, R] {\n")
fmt.Fprintf(f, " return func(")
for j := 0; j < i; j++ {
if j > 0 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "t%d T%d", j, j)
}
fmt.Fprintf(f, ") Either[error, R] {\n")
fmt.Fprintf(f, " return TryCatchError(func() (R, error) {\n")
fmt.Fprintf(f, " return f(")
for j := 0; j < i; j++ {
if j > 0 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "t%d", j)
}
fmt.Fprintln(f, ")")
fmt.Fprintln(f, " })")
fmt.Fprintln(f, " }")
fmt.Fprintln(f, "}")
}
func generateEitherHelpers(filename string, count int) error {
dir, err := os.Getwd()
if err != nil {
return err
}
absDir, err := filepath.Abs(dir)
if err != nil {
return err
}
pkg := filepath.Base(absDir)
f, err := os.Create(filename)
if err != nil {
return err
}
defer f.Close()
// log
log.Printf("Generating code in [%s] for package [%s] with [%d] repetitions ...", filename, pkg, count)
// some header
fmt.Fprintln(f, "// Code generated by go generate; DO NOT EDIT.")
fmt.Fprintln(f, "// This file was generated by robots at")
fmt.Fprintf(f, "// %s\n", time.Now())
fmt.Fprintf(f, "package %s\n\n", pkg)
// zero level functions
// optionize
generateEitherize(f, 0)
// unoptionize
generateUneitherize(f, 0)
for i := 1; i <= count; i++ {
// optionize
generateEitherize(f, i)
// unoptionize
generateUneitherize(f, i)
}
return nil
}
func EitherCommand() *C.Command {
return &C.Command{
Name: "either",
Usage: "generate code for Either",
Flags: []C.Flag{
flagCount,
flagFilename,
},
Action: func(ctx *C.Context) error {
return generateEitherHelpers(
ctx.String(keyFilename),
ctx.Int(keyCount),
)
},
}
}

166
cli/option.go Normal file
View File

@@ -0,0 +1,166 @@
package cli
import (
"fmt"
"log"
"os"
"path/filepath"
"time"
C "github.com/urfave/cli/v2"
)
func generateOptionize(f *os.File, i int) {
// Create the optionize version
fmt.Fprintf(f, "\n// Optionize%d converts a function with %d parameters returning a tuple of a return value R and a boolean into a function with %d parameters returning an Option[R]\n", i, i, i)
fmt.Fprintf(f, "func Optionize%d[F ~func(", i)
for j := 0; j < i; j++ {
if j > 0 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "T%d", j)
}
fmt.Fprintf(f, ") (R, bool)")
for j := 0; j < i; j++ {
fmt.Fprintf(f, ", T%d", j)
}
fmt.Fprintf(f, ", R any](f F) func(")
for j := 0; j < i; j++ {
if j > 0 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "T%d", j)
}
fmt.Fprintf(f, ") Option[R] {\n")
fmt.Fprintf(f, " return func(")
for j := 0; j < i; j++ {
if j > 0 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "t%d T%d", j, j)
}
fmt.Fprintf(f, ") Option[R] {\n")
fmt.Fprintf(f, " return optionize(func() (R, bool) {\n")
fmt.Fprintf(f, " return f(")
for j := 0; j < i; j++ {
if j > 0 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "t%d", j)
}
fmt.Fprintln(f, ")")
fmt.Fprintln(f, " })")
fmt.Fprintln(f, " }")
fmt.Fprintln(f, "}")
}
func generateUnoptionize(f *os.File, i int) {
// Create the optionize version
fmt.Fprintf(f, "\n// Unoptionize%d converts a function with %d parameters returning a tuple of a return value R and a boolean into a function with %d parameters returning an Option[R]\n", i, i, i)
fmt.Fprintf(f, "func Unoptionize%d[F ~func(", i)
for j := 0; j < i; j++ {
if j > 0 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "T%d", j)
}
fmt.Fprintf(f, ") Option[R]")
for j := 0; j < i; j++ {
fmt.Fprintf(f, ", T%d", j)
}
fmt.Fprintf(f, ", R any](f F) func(")
for j := 0; j < i; j++ {
if j > 0 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "T%d", j)
}
fmt.Fprintf(f, ") (R, bool) {\n")
fmt.Fprintf(f, " return func(")
for j := 0; j < i; j++ {
if j > 0 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "t%d T%d", j, j)
}
fmt.Fprintf(f, ") (R, bool) {\n")
fmt.Fprintf(f, " return Unwrap(f(")
for j := 0; j < i; j++ {
if j > 0 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "t%d", j)
}
fmt.Fprintln(f, "))")
fmt.Fprintln(f, " }")
fmt.Fprintln(f, "}")
}
func generateOptionHelpers(filename string, count int) error {
dir, err := os.Getwd()
if err != nil {
return err
}
absDir, err := filepath.Abs(dir)
if err != nil {
return err
}
pkg := filepath.Base(absDir)
f, err := os.Create(filename)
if err != nil {
return err
}
defer f.Close()
// log
log.Printf("Generating code in [%s] for package [%s] with [%d] repetitions ...", filename, pkg, count)
// some header
fmt.Fprintln(f, "// Code generated by go generate; DO NOT EDIT.")
fmt.Fprintln(f, "// This file was generated by robots at")
fmt.Fprintf(f, "// %s\n", time.Now())
fmt.Fprintf(f, "package %s\n\n", pkg)
// print out some helpers
fmt.Fprintf(f, `// optionize converts a nullary function to an option
func optionize[R any](f func() (R, bool)) Option[R] {
if r, ok := f(); ok {
return Some(r)
}
return None[R]()
}
`)
// zero level functions
// optionize
generateOptionize(f, 0)
// unoptionize
generateUnoptionize(f, 0)
for i := 1; i <= count; i++ {
// optionize
generateOptionize(f, i)
// unoptionize
generateUnoptionize(f, i)
}
return nil
}
func OptionCommand() *C.Command {
return &C.Command{
Name: "option",
Usage: "generate code for Option",
Flags: []C.Flag{
flagCount,
flagFilename,
},
Action: func(ctx *C.Context) error {
return generateOptionHelpers(
ctx.String(keyFilename),
ctx.Int(keyCount),
)
},
}
}

View File

@@ -10,23 +10,141 @@ import (
C "github.com/urfave/cli/v2" C "github.com/urfave/cli/v2"
) )
const ( func generateVariadic(f *os.File, i int) {
keyCount = "count"
)
func generateNullary(f *os.File, i int) {
// Create the nullary version // Create the nullary version
fmt.Fprintf(f, "\n// Nullary%d creates a parameter less function from a parameter less function and %d functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions\n", i, i-1) fmt.Fprintf(f, "\n// Variadic%d converts a function taking %d parameters and a final slice into a function with %d parameters but a final variadic argument\n", i, i, i)
fmt.Fprintf(f, "func Nullary%d[", i) fmt.Fprintf(f, "func Variadic%d[", i)
for j := 1; j <= i; j++ { for j := 1; j <= i; j++ {
if j > 1 { if j > 1 {
fmt.Fprintf(f, ", ") fmt.Fprintf(f, ", ")
} }
fmt.Fprintf(f, "T%d", j) fmt.Fprintf(f, "T%d", j)
} }
fmt.Fprintf(f, " any](f1 func() T1") if i > 0 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "V, R any](f func(")
for j := 1; j <= i; j++ {
if j > 1 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "T%d", j)
}
if i > 0 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "[]V) R) func(")
for j := 1; j <= i; j++ {
if j > 1 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "T%d", j)
}
if i > 0 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "...V) R {\n")
fmt.Fprintf(f, " return func(")
for j := 1; j <= i; j++ {
if j > 1 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "t%d T%d", j, j)
}
if i > 0 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "v ...V) R {\n")
fmt.Fprintf(f, " return f(")
for j := 1; j <= i; j++ {
if j > 1 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "t%d", j)
}
if i > 0 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "v)\n")
fmt.Fprintf(f, " }\n")
fmt.Fprintf(f, "}")
}
func generateUnvariadic(f *os.File, i int) {
// Create the nullary version
fmt.Fprintf(f, "\n// Unvariadic%d converts a function taking %d parameters and a final variadic argument into a function with %d parameters but a final slice argument\n", i, i, i)
fmt.Fprintf(f, "func Unvariadic%d[", i)
for j := 1; j <= i; j++ {
if j > 1 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "T%d", j)
}
if i > 0 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "V, R any](f func(")
for j := 1; j <= i; j++ {
if j > 1 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "T%d", j)
}
if i > 0 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "...V) R) func(")
for j := 1; j <= i; j++ {
if j > 1 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "T%d", j)
}
if i > 0 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "[]V) R {\n")
fmt.Fprintf(f, " return func(")
for j := 1; j <= i; j++ {
if j > 1 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "t%d T%d", j, j)
}
if i > 0 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "v []V) R {\n")
fmt.Fprintf(f, " return f(")
for j := 1; j <= i; j++ {
if j > 1 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "t%d", j)
}
if i > 0 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "v...)\n")
fmt.Fprintf(f, " }\n")
fmt.Fprintf(f, "}")
}
func generateNullary(f *os.File, i int) {
// Create the nullary version
fmt.Fprintf(f, "\n// Nullary%d creates a parameter less function from a parameter less function and %d functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions\n", i, i-1)
fmt.Fprintf(f, "func Nullary%d[F1 ~func() T1", i)
for j := 2; j <= i; j++ { for j := 2; j <= i; j++ {
fmt.Fprintf(f, ", f%d func(T%d) T%d", j, j-1, j) fmt.Fprintf(f, ", F%d ~func(T%d) T%d", j, j-1, j)
}
for j := 1; j <= i; j++ {
fmt.Fprintf(f, ", T%d", j)
}
fmt.Fprintf(f, " any](f1 F1")
for j := 2; j <= i; j++ {
fmt.Fprintf(f, ", f%d F%d", j, j)
} }
fmt.Fprintf(f, ") func() T%d {\n", i) fmt.Fprintf(f, ") func() T%d {\n", i)
fmt.Fprintf(f, " return func() T%d {\n", i) fmt.Fprintf(f, " return func() T%d {\n", i)
@@ -42,9 +160,15 @@ func generateNullary(f *os.File, i int) {
func generateFlow(f *os.File, i int) { func generateFlow(f *os.File, i int) {
// Create the flow version // Create the flow version
fmt.Fprintf(f, "\n// Flow%d creates a function that takes an initial value t0 and sucessively applies %d functions where the input of a function is the return value of the previous function\n// The final return value is the result of the last function application\n", i, i) fmt.Fprintf(f, "\n// Flow%d creates a function that takes an initial value t0 and successively applies %d functions where the input of a function is the return value of the previous function\n// The final return value is the result of the last function application\n", i, i)
fmt.Fprintf(f, "func Flow%d[T0", i) fmt.Fprintf(f, "func Flow%d[", i)
for j := 1; j <= i; j++ { for j := 1; j <= i; j++ {
if j > 1 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "F%d ~func(T%d) T%d", j, j-1, j)
}
for j := 0; j <= i; j++ {
fmt.Fprintf(f, ", T%d", j) fmt.Fprintf(f, ", T%d", j)
} }
fmt.Fprintf(f, " any](") fmt.Fprintf(f, " any](")
@@ -52,7 +176,7 @@ func generateFlow(f *os.File, i int) {
if j > 1 { if j > 1 {
fmt.Fprintf(f, ", ") fmt.Fprintf(f, ", ")
} }
fmt.Fprintf(f, "f%d func(T%d) T%d", j, j-1, j) fmt.Fprintf(f, "f%d F%d", j, j)
} }
fmt.Fprintf(f, ") func(T0) T%d {\n", i) fmt.Fprintf(f, ") func(T0) T%d {\n", i)
fmt.Fprintf(f, " return func(t0 T0) T%d {\n", i) fmt.Fprintf(f, " return func(t0 T0) T%d {\n", i)
@@ -69,14 +193,27 @@ func generateFlow(f *os.File, i int) {
func generatePipe(f *os.File, i int) { func generatePipe(f *os.File, i int) {
// Create the pipe version // Create the pipe version
fmt.Fprintf(f, "\n// Pipe%d takes an initial value t0 and sucessively applies %d functions where the input of a function is the return value of the previous function\n// The final return value is the result of the last function application\n", i, i) fmt.Fprintf(f, "\n// Pipe%d takes an initial value t0 and successively applies %d functions where the input of a function is the return value of the previous function\n// The final return value is the result of the last function application\n", i, i)
fmt.Fprintf(f, "func Pipe%d[T0", i) fmt.Fprintf(f, "func Pipe%d[", i)
for j := 1; j <= i; j++ { for j := 1; j <= i; j++ {
fmt.Fprintf(f, ", T%d", j) if j > 1 {
fmt.Fprintf(f, ", ")
} }
fmt.Fprintf(f, "F%d ~func(T%d) T%d", j, j-1, j)
}
if i > 0 {
fmt.Fprintf(f, ", ")
}
for j := 0; j <= i; j++ {
if j > 0 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "T%d", j)
}
fmt.Fprintf(f, " any](t0 T0") fmt.Fprintf(f, " any](t0 T0")
for j := 1; j <= i; j++ { for j := 1; j <= i; j++ {
fmt.Fprintf(f, ", f%d func(T%d) T%d", j, j-1, j) fmt.Fprintf(f, ", f%d F%d", j, j)
} }
fmt.Fprintf(f, ") T%d {\n", i) fmt.Fprintf(f, ") T%d {\n", i)
for j := 1; j <= i; j++ { for j := 1; j <= i; j++ {
@@ -164,7 +301,7 @@ func generateUncurry(f *os.File, i int) {
fmt.Fprintf(f, "}\n") fmt.Fprintf(f, "}\n")
} }
func generateHelpers(count int) error { func generatePipeHelpers(filename string, count int) error {
dir, err := os.Getwd() dir, err := os.Getwd()
if err != nil { if err != nil {
return err return err
@@ -174,13 +311,13 @@ func generateHelpers(count int) error {
return err return err
} }
pkg := filepath.Base(absDir) pkg := filepath.Base(absDir)
f, err := os.Create("gen.go") f, err := os.Create(filename)
if err != nil { if err != nil {
return err return err
} }
defer f.Close() defer f.Close()
// log // log
log.Printf("Generating code for package [%s] with [%d] repetitions ...", pkg, count) log.Printf("Generating code in [%s] for package [%s] with [%d] repetitions ...", filename, pkg, count)
// some header // some header
fmt.Fprintln(f, "// Code generated by go generate; DO NOT EDIT.") fmt.Fprintln(f, "// Code generated by go generate; DO NOT EDIT.")
@@ -189,6 +326,13 @@ func generateHelpers(count int) error {
fmt.Fprintf(f, "package %s\n", pkg) fmt.Fprintf(f, "package %s\n", pkg)
// pipe
generatePipe(f, 0)
// variadic
generateVariadic(f, 0)
// unvariadic
generateUnvariadic(f, 0)
for i := 1; i <= count; i++ { for i := 1; i <= count; i++ {
// pipe // pipe
@@ -201,6 +345,10 @@ func generateHelpers(count int) error {
generateCurry(f, i) generateCurry(f, i)
// uncurry // uncurry
generateUncurry(f, i) generateUncurry(f, i)
// variadic
generateVariadic(f, i)
// unvariadic
generateUnvariadic(f, i)
} }
return nil return nil
@@ -209,15 +357,17 @@ func generateHelpers(count int) error {
func PipeCommand() *C.Command { func PipeCommand() *C.Command {
return &C.Command{ return &C.Command{
Name: "pipe", Name: "pipe",
Usage: "generate code for pipe, flow, curry, etc",
Description: "Code generation for pipe, flow, curry, etc",
Flags: []C.Flag{ Flags: []C.Flag{
&C.IntFlag{ flagCount,
Name: keyCount, flagFilename,
Value: 20,
Usage: "Number of variations to create",
},
}, },
Action: func(ctx *C.Context) error { Action: func(ctx *C.Context) error {
return generateHelpers(ctx.Int(keyCount)) return generatePipeHelpers(
ctx.String(keyFilename),
ctx.Int(keyCount),
)
}, },
} }
} }

View File

@@ -52,6 +52,7 @@ func MonadFold[E, A, B any](ma Either[E, A], onLeft func(e E) B, onRight func(a
return onRight(ma.right) return onRight(ma.right)
} }
// Unwrap converts an Either into the idiomatic tuple
func Unwrap[E, A any](ma Either[E, A]) (A, E) { func Unwrap[E, A any](ma Either[E, A]) (A, E) {
return ma.right, ma.left return ma.right, ma.left
} }

3
either/doc.go Normal file
View File

@@ -0,0 +1,3 @@
package either
//go:generate go run .. either --count 10 --filename eitherize.go

View File

@@ -102,7 +102,7 @@ func Flatten[E, A any](mma Either[E, Either[E, A]]) Either[E, A] {
return MonadChain(mma, F.Identity[Either[E, A]]) return MonadChain(mma, F.Identity[Either[E, A]])
} }
func TryCatch[E, A any](f func() (A, error), onThrow func(error) E) Either[E, A] { func TryCatch[FA ~func() (A, error), FE func(error) E, E, A any](f FA, onThrow FE) Either[E, A] {
val, err := f() val, err := f()
if err != nil { if err != nil {
return F.Pipe2(err, onThrow, Left[E, A]) return F.Pipe2(err, onThrow, Left[E, A])
@@ -110,14 +110,10 @@ func TryCatch[E, A any](f func() (A, error), onThrow func(error) E) Either[E, A]
return F.Pipe1(val, Right[E, A]) return F.Pipe1(val, Right[E, A])
} }
func TryCatchErrorG[GA ~func() (A, error), A any](f GA) Either[error, A] { func TryCatchError[F ~func() (A, error), A any](f F) Either[error, A] {
return TryCatch(f, E.IdentityError) return TryCatch(f, E.IdentityError)
} }
func TryCatchError[A any](f func() (A, error)) Either[error, A] {
return TryCatchErrorG(f)
}
func Sequence2[E, T1, T2, R any](f func(T1, T2) Either[E, R]) func(Either[E, T1], Either[E, T2]) Either[E, R] { func Sequence2[E, T1, T2, R any](f func(T1, T2) Either[E, R]) func(Either[E, T1], Either[E, T2]) Either[E, R] {
return func(e1 Either[E, T1], e2 Either[E, T2]) Either[E, R] { return func(e1 Either[E, T1], e2 Either[E, T2]) Either[E, R] {
return MonadSequence2(e1, e2, f) return MonadSequence2(e1, e2, f)
@@ -150,118 +146,13 @@ func ToError[A any](e Either[error, A]) error {
return MonadFold(e, E.IdentityError, F.Constant1[A, error](nil)) return MonadFold(e, E.IdentityError, F.Constant1[A, error](nil))
} }
func Eitherize0G[GA ~func() (R, error), GB ~func() Either[error, R], R any](f GA) GB {
return F.Bind1(TryCatchErrorG[GA, R], f)
}
func Eitherize0[R any](f func() (R, error)) func() Either[error, R] {
return Eitherize0G[func() (R, error), func() Either[error, R]](f)
}
func Uneitherize0G[GA ~func() Either[error, R], GB ~func() (R, error), R any](f GA) GB {
return func() (R, error) {
return UnwrapError(f())
}
}
func Uneitherize0[R any](f func() Either[error, R]) func() (R, error) {
return Uneitherize0G[func() Either[error, R], func() (R, error)](f)
}
func Eitherize1G[GA ~func(T1) (R, error), GB ~func(T1) Either[error, R], T1, R any](f GA) GB {
return func(t1 T1) Either[error, R] {
return TryCatchError(func() (R, error) {
return f(t1)
})
}
}
func Eitherize1[T1, R any](f func(T1) (R, error)) func(T1) Either[error, R] {
return Eitherize1G[func(T1) (R, error), func(T1) Either[error, R]](f)
}
func Uneitherize1G[GA ~func(T1) Either[error, R], GB ~func(T1) (R, error), T1, R any](f GA) GB {
return func(t1 T1) (R, error) {
return UnwrapError(f(t1))
}
}
func Uneitherize1[T1, R any](f func(T1) Either[error, R]) func(T1) (R, error) {
return Uneitherize1G[func(T1) Either[error, R], func(T1) (R, error)](f)
}
func Eitherize2G[GA ~func(t1 T1, t2 T2) (R, error), GB ~func(t1 T1, t2 T2) Either[error, R], T1, T2, R any](f GA) GB {
return func(t1 T1, t2 T2) Either[error, R] {
return TryCatchError(func() (R, error) {
return f(t1, t2)
})
}
}
func Eitherize2[T1, T2, R any](f func(t1 T1, t2 T2) (R, error)) func(t1 T1, t2 T2) Either[error, R] {
return Eitherize2G[func(t1 T1, t2 T2) (R, error), func(t1 T1, t2 T2) Either[error, R]](f)
}
func Uneitherize2G[GA ~func(T1, T2) Either[error, R], GB ~func(T1, T2) (R, error), T1, T2, R any](f GA) GB {
return func(t1 T1, t2 T2) (R, error) {
return UnwrapError(f(t1, t2))
}
}
func Uneitherize2[T1, T2, R any](f func(T1, T2) Either[error, R]) func(T1, T2) (R, error) {
return Uneitherize2G[func(T1, T2) Either[error, R], func(T1, T2) (R, error)](f)
}
func Eitherize3G[GA ~func(t1 T1, t2 T2, t3 T3) (R, error), GB ~func(t1 T1, t2 T2, t3 T3) Either[error, R], T1, T2, T3, R any](f GA) GB {
return func(t1 T1, t2 T2, t3 T3) Either[error, R] {
return TryCatchError(func() (R, error) {
return f(t1, t2, t3)
})
}
}
func Eitherize3[T1, T2, T3, R any](f func(t1 T1, t2 T2, t3 T3) (R, error)) func(t1 T1, t2 T2, t3 T3) Either[error, R] {
return Eitherize3G[func(t1 T1, t2 T2, t3 T3) (R, error), func(t1 T1, t2 T2, t3 T3) Either[error, R]](f)
}
func Uneitherize3G[GA ~func(T1, T2, T3) Either[error, R], GB ~func(T1, T2, T3) (R, error), T1, T2, T3, R any](f GA) GB {
return func(t1 T1, t2 T2, t3 T3) (R, error) {
return UnwrapError(f(t1, t2, t3))
}
}
func Uneitherize3[T1, T2, T3, R any](f func(T1, T2, T3) Either[error, R]) func(T1, T2, T3) (R, error) {
return Uneitherize3G[func(T1, T2, T3) Either[error, R], func(T1, T2, T3) (R, error)](f)
}
func Eitherize4G[GA ~func(t1 T1, t2 T2, t3 T3, t4 T4) (R, error), GB ~func(t1 T1, t2 T2, t3 T3, t4 T4) Either[error, R], T1, T2, T3, T4, R any](f GA) GB {
return func(t1 T1, t2 T2, t3 T3, t4 T4) Either[error, R] {
return TryCatchError(func() (R, error) {
return f(t1, t2, t3, t4)
})
}
}
func Eitherize4[T1, T2, T3, T4, R any](f func(t1 T1, t2 T2, t3 T3, t4 T4) (R, error)) func(t1 T1, t2 T2, t3 T3, t4 T4) Either[error, R] {
return Eitherize4G[func(t1 T1, t2 T2, t3 T3, t4 T4) (R, error), func(t1 T1, t2 T2, t3 T3, t4 T4) Either[error, R]](f)
}
func Uneitherize4G[GA ~func(T1, T2, T3, T4) Either[error, R], GB ~func(T1, T2, T3, T4) (R, error), T1, T2, T3, T4, R any](f GA) GB {
return func(t1 T1, t2 T2, t3 T3, t4 T4) (R, error) {
return UnwrapError(f(t1, t2, t3, t4))
}
}
func Uneitherize4[T1, T2, T3, T4, R any](f func(T1, T2, T3, T4) Either[error, R]) func(T1, T2, T3, T4) (R, error) {
return Uneitherize4G[func(T1, T2, T3, T4) Either[error, R], func(T1, T2, T3, T4) (R, error)](f)
}
func Fold[E, A, B any](onLeft func(E) B, onRight func(A) B) func(Either[E, A]) B { func Fold[E, A, B any](onLeft func(E) B, onRight func(A) B) func(Either[E, A]) B {
return func(ma Either[E, A]) B { return func(ma Either[E, A]) B {
return MonadFold(ma, onLeft, onRight) return MonadFold(ma, onLeft, onRight)
} }
} }
// UnwrapError converts an Either into the idiomatic tuple
func UnwrapError[A any](ma Either[error, A]) (A, error) { func UnwrapError[A any](ma Either[error, A]) (A, error) {
return Unwrap[error](ma) return Unwrap[error](ma)
} }

180
either/eitherize.go Normal file
View File

@@ -0,0 +1,180 @@
// Code generated by go generate; DO NOT EDIT.
// This file was generated by robots at
// 2023-07-13 16:10:30.7402002 +0200 CEST m=+0.008416101
package either
// Eitherize0 converts a function with 0 parameters returning a tuple into a function with 0 parameters returning an Either
func Eitherize0[F ~func() (R, error), R any](f F) func() Either[error, R] {
return func() Either[error, R] {
return TryCatchError(func() (R, error) {
return f()
})
}
}
// Uneitherize0 converts a function with 0 parameters returning an Either into a function with 0 parameters returning a tuple
func Uneitherize0[F ~func() Either[error, R], R any](f F) func() (R, error) {
return func() (R, error) {
return UnwrapError(f())
}
}
// Eitherize1 converts a function with 1 parameters returning a tuple into a function with 1 parameters returning an Either
func Eitherize1[F ~func(T0) (R, error), T0, R any](f F) func(T0) Either[error, R] {
return func(t0 T0) Either[error, R] {
return TryCatchError(func() (R, error) {
return f(t0)
})
}
}
// Uneitherize1 converts a function with 1 parameters returning an Either into a function with 1 parameters returning a tuple
func Uneitherize1[F ~func(T0) Either[error, R], T0, R any](f F) func(T0) (R, error) {
return func(t0 T0) (R, error) {
return UnwrapError(f(t0))
}
}
// Eitherize2 converts a function with 2 parameters returning a tuple into a function with 2 parameters returning an Either
func Eitherize2[F ~func(T0, T1) (R, error), T0, T1, R any](f F) func(T0, T1) Either[error, R] {
return func(t0 T0, t1 T1) Either[error, R] {
return TryCatchError(func() (R, error) {
return f(t0, t1)
})
}
}
// Uneitherize2 converts a function with 2 parameters returning an Either into a function with 2 parameters returning a tuple
func Uneitherize2[F ~func(T0, T1) Either[error, R], T0, T1, R any](f F) func(T0, T1) (R, error) {
return func(t0 T0, t1 T1) (R, error) {
return UnwrapError(f(t0, t1))
}
}
// Eitherize3 converts a function with 3 parameters returning a tuple into a function with 3 parameters returning an Either
func Eitherize3[F ~func(T0, T1, T2) (R, error), T0, T1, T2, R any](f F) func(T0, T1, T2) Either[error, R] {
return func(t0 T0, t1 T1, t2 T2) Either[error, R] {
return TryCatchError(func() (R, error) {
return f(t0, t1, t2)
})
}
}
// Uneitherize3 converts a function with 3 parameters returning an Either into a function with 3 parameters returning a tuple
func Uneitherize3[F ~func(T0, T1, T2) Either[error, R], T0, T1, T2, R any](f F) func(T0, T1, T2) (R, error) {
return func(t0 T0, t1 T1, t2 T2) (R, error) {
return UnwrapError(f(t0, t1, t2))
}
}
// Eitherize4 converts a function with 4 parameters returning a tuple into a function with 4 parameters returning an Either
func Eitherize4[F ~func(T0, T1, T2, T3) (R, error), T0, T1, T2, T3, R any](f F) func(T0, T1, T2, T3) Either[error, R] {
return func(t0 T0, t1 T1, t2 T2, t3 T3) Either[error, R] {
return TryCatchError(func() (R, error) {
return f(t0, t1, t2, t3)
})
}
}
// Uneitherize4 converts a function with 4 parameters returning an Either into a function with 4 parameters returning a tuple
func Uneitherize4[F ~func(T0, T1, T2, T3) Either[error, R], T0, T1, T2, T3, R any](f F) func(T0, T1, T2, T3) (R, error) {
return func(t0 T0, t1 T1, t2 T2, t3 T3) (R, error) {
return UnwrapError(f(t0, t1, t2, t3))
}
}
// Eitherize5 converts a function with 5 parameters returning a tuple into a function with 5 parameters returning an Either
func Eitherize5[F ~func(T0, T1, T2, T3, T4) (R, error), T0, T1, T2, T3, T4, R any](f F) func(T0, T1, T2, T3, T4) Either[error, R] {
return func(t0 T0, t1 T1, t2 T2, t3 T3, t4 T4) Either[error, R] {
return TryCatchError(func() (R, error) {
return f(t0, t1, t2, t3, t4)
})
}
}
// Uneitherize5 converts a function with 5 parameters returning an Either into a function with 5 parameters returning a tuple
func Uneitherize5[F ~func(T0, T1, T2, T3, T4) Either[error, R], T0, T1, T2, T3, T4, R any](f F) func(T0, T1, T2, T3, T4) (R, error) {
return func(t0 T0, t1 T1, t2 T2, t3 T3, t4 T4) (R, error) {
return UnwrapError(f(t0, t1, t2, t3, t4))
}
}
// Eitherize6 converts a function with 6 parameters returning a tuple into a function with 6 parameters returning an Either
func Eitherize6[F ~func(T0, T1, T2, T3, T4, T5) (R, error), T0, T1, T2, T3, T4, T5, R any](f F) func(T0, T1, T2, T3, T4, T5) Either[error, R] {
return func(t0 T0, t1 T1, t2 T2, t3 T3, t4 T4, t5 T5) Either[error, R] {
return TryCatchError(func() (R, error) {
return f(t0, t1, t2, t3, t4, t5)
})
}
}
// Uneitherize6 converts a function with 6 parameters returning an Either into a function with 6 parameters returning a tuple
func Uneitherize6[F ~func(T0, T1, T2, T3, T4, T5) Either[error, R], T0, T1, T2, T3, T4, T5, R any](f F) func(T0, T1, T2, T3, T4, T5) (R, error) {
return func(t0 T0, t1 T1, t2 T2, t3 T3, t4 T4, t5 T5) (R, error) {
return UnwrapError(f(t0, t1, t2, t3, t4, t5))
}
}
// Eitherize7 converts a function with 7 parameters returning a tuple into a function with 7 parameters returning an Either
func Eitherize7[F ~func(T0, T1, T2, T3, T4, T5, T6) (R, error), T0, T1, T2, T3, T4, T5, T6, R any](f F) func(T0, T1, T2, T3, T4, T5, T6) Either[error, R] {
return func(t0 T0, t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6) Either[error, R] {
return TryCatchError(func() (R, error) {
return f(t0, t1, t2, t3, t4, t5, t6)
})
}
}
// Uneitherize7 converts a function with 7 parameters returning an Either into a function with 7 parameters returning a tuple
func Uneitherize7[F ~func(T0, T1, T2, T3, T4, T5, T6) Either[error, R], T0, T1, T2, T3, T4, T5, T6, R any](f F) func(T0, T1, T2, T3, T4, T5, T6) (R, error) {
return func(t0 T0, t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6) (R, error) {
return UnwrapError(f(t0, t1, t2, t3, t4, t5, t6))
}
}
// Eitherize8 converts a function with 8 parameters returning a tuple into a function with 8 parameters returning an Either
func Eitherize8[F ~func(T0, T1, T2, T3, T4, T5, T6, T7) (R, error), T0, T1, T2, T3, T4, T5, T6, T7, R any](f F) func(T0, T1, T2, T3, T4, T5, T6, T7) Either[error, R] {
return func(t0 T0, t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7) Either[error, R] {
return TryCatchError(func() (R, error) {
return f(t0, t1, t2, t3, t4, t5, t6, t7)
})
}
}
// Uneitherize8 converts a function with 8 parameters returning an Either into a function with 8 parameters returning a tuple
func Uneitherize8[F ~func(T0, T1, T2, T3, T4, T5, T6, T7) Either[error, R], T0, T1, T2, T3, T4, T5, T6, T7, R any](f F) func(T0, T1, T2, T3, T4, T5, T6, T7) (R, error) {
return func(t0 T0, t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7) (R, error) {
return UnwrapError(f(t0, t1, t2, t3, t4, t5, t6, t7))
}
}
// Eitherize9 converts a function with 9 parameters returning a tuple into a function with 9 parameters returning an Either
func Eitherize9[F ~func(T0, T1, T2, T3, T4, T5, T6, T7, T8) (R, error), T0, T1, T2, T3, T4, T5, T6, T7, T8, R any](f F) func(T0, T1, T2, T3, T4, T5, T6, T7, T8) Either[error, R] {
return func(t0 T0, t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8) Either[error, R] {
return TryCatchError(func() (R, error) {
return f(t0, t1, t2, t3, t4, t5, t6, t7, t8)
})
}
}
// Uneitherize9 converts a function with 9 parameters returning an Either into a function with 9 parameters returning a tuple
func Uneitherize9[F ~func(T0, T1, T2, T3, T4, T5, T6, T7, T8) Either[error, R], T0, T1, T2, T3, T4, T5, T6, T7, T8, R any](f F) func(T0, T1, T2, T3, T4, T5, T6, T7, T8) (R, error) {
return func(t0 T0, t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8) (R, error) {
return UnwrapError(f(t0, t1, t2, t3, t4, t5, t6, t7, t8))
}
}
// Eitherize10 converts a function with 10 parameters returning a tuple into a function with 10 parameters returning an Either
func Eitherize10[F ~func(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9) (R, error), T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, R any](f F) func(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9) Either[error, R] {
return func(t0 T0, t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8, t9 T9) Either[error, R] {
return TryCatchError(func() (R, error) {
return f(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9)
})
}
}
// Uneitherize10 converts a function with 10 parameters returning an Either into a function with 10 parameters returning a tuple
func Uneitherize10[F ~func(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9) Either[error, R], T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, R any](f F) func(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9) (R, error) {
return func(t0 T0, t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8, t9 T9) (R, error) {
return UnwrapError(f(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9))
}
}

View File

@@ -1,3 +1,3 @@
package function package function
//go:generate go run .. pipe --count 20 //go:generate go run .. pipe --count 20 --filename gen.go

View File

@@ -1,9 +1,5 @@
package function package function
func Pipe0[T0 any](t0 T0) T0 {
return t0
}
// Identity returns the value 'a' // Identity returns the value 'a'
func Identity[A any](a A) A { func Identity[A any](a A) A {
return a return a

View File

@@ -1,25 +1,45 @@
// Code generated by go generate; DO NOT EDIT. // Code generated by go generate; DO NOT EDIT.
// This file was generated by robots at // This file was generated by robots at
// 2023-07-10 12:39:43.3709934 +0200 CEST m=+0.009192101 // 2023-07-13 16:11:39.4638087 +0200 CEST m=+0.008945901
package function package function
// Pipe1 takes an initial value t0 and sucessively applies 1 functions where the input of a function is the return value of the previous function // Pipe0 takes an initial value t0 and successively applies 0 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Pipe1[T0, T1 any](t0 T0, f1 func(T0) T1) T1 { func Pipe0[T0 any](t0 T0) T0 {
return t0
}
// Variadic0 converts a function taking 0 parameters and a final slice into a function with 0 parameters but a final variadic argument
func Variadic0[V, R any](f func([]V) R) func(...V) R {
return func(v ...V) R {
return f(v)
}
}
// Unvariadic0 converts a function taking 0 parameters and a final variadic argument into a function with 0 parameters but a final slice argument
func Unvariadic0[V, R any](f func(...V) R) func([]V) R {
return func(v []V) R {
return f(v...)
}
}
// Pipe1 takes an initial value t0 and successively applies 1 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application
func Pipe1[F1 ~func(T0) T1, T0, T1 any](t0 T0, f1 F1) T1 {
t1 := f1(t0) t1 := f1(t0)
return t1 return t1
} }
// Flow1 creates a function that takes an initial value t0 and sucessively applies 1 functions where the input of a function is the return value of the previous function // Flow1 creates a function that takes an initial value t0 and successively applies 1 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Flow1[T0, T1 any](f1 func(T0) T1) func(T0) T1 { func Flow1[F1 ~func(T0) T1, T0, T1 any](f1 F1) func(T0) T1 {
return func(t0 T0) T1 { return func(t0 T0) T1 {
return Pipe1(t0, f1) return Pipe1(t0, f1)
} }
} }
// Nullary1 creates a parameter less function from a parameter less function and 0 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions // Nullary1 creates a parameter less function from a parameter less function and 0 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions
func Nullary1[T1 any](f1 func() T1) func() T1 { func Nullary1[F1 ~func() T1, T1 any](f1 F1) func() T1 {
return func() T1 { return func() T1 {
return Pipe0(f1()) return Pipe0(f1())
} }
@@ -41,24 +61,38 @@ func Uncurry1[T0, T1 any](f func(T0) T1) func(T0) T1 {
} }
} }
// Pipe2 takes an initial value t0 and sucessively applies 2 functions where the input of a function is the return value of the previous function // Variadic1 converts a function taking 1 parameters and a final slice into a function with 1 parameters but a final variadic argument
func Variadic1[T1, V, R any](f func(T1, []V) R) func(T1, ...V) R {
return func(t1 T1, v ...V) R {
return f(t1, v)
}
}
// Unvariadic1 converts a function taking 1 parameters and a final variadic argument into a function with 1 parameters but a final slice argument
func Unvariadic1[T1, V, R any](f func(T1, ...V) R) func(T1, []V) R {
return func(t1 T1, v []V) R {
return f(t1, v...)
}
}
// Pipe2 takes an initial value t0 and successively applies 2 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Pipe2[T0, T1, T2 any](t0 T0, f1 func(T0) T1, f2 func(T1) T2) T2 { func Pipe2[F1 ~func(T0) T1, F2 ~func(T1) T2, T0, T1, T2 any](t0 T0, f1 F1, f2 F2) T2 {
t1 := f1(t0) t1 := f1(t0)
t2 := f2(t1) t2 := f2(t1)
return t2 return t2
} }
// Flow2 creates a function that takes an initial value t0 and sucessively applies 2 functions where the input of a function is the return value of the previous function // Flow2 creates a function that takes an initial value t0 and successively applies 2 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Flow2[T0, T1, T2 any](f1 func(T0) T1, f2 func(T1) T2) func(T0) T2 { func Flow2[F1 ~func(T0) T1, F2 ~func(T1) T2, T0, T1, T2 any](f1 F1, f2 F2) func(T0) T2 {
return func(t0 T0) T2 { return func(t0 T0) T2 {
return Pipe2(t0, f1, f2) return Pipe2(t0, f1, f2)
} }
} }
// Nullary2 creates a parameter less function from a parameter less function and 1 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions // Nullary2 creates a parameter less function from a parameter less function and 1 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions
func Nullary2[T1, T2 any](f1 func() T1, f2 func(T1) T2) func() T2 { func Nullary2[F1 ~func() T1, F2 ~func(T1) T2, T1, T2 any](f1 F1, f2 F2) func() T2 {
return func() T2 { return func() T2 {
return Pipe1(f1(), f2) return Pipe1(f1(), f2)
} }
@@ -82,25 +116,39 @@ func Uncurry2[T0, T1, T2 any](f func(T0) func(T1) T2) func(T0, T1) T2 {
} }
} }
// Pipe3 takes an initial value t0 and sucessively applies 3 functions where the input of a function is the return value of the previous function // Variadic2 converts a function taking 2 parameters and a final slice into a function with 2 parameters but a final variadic argument
func Variadic2[T1, T2, V, R any](f func(T1, T2, []V) R) func(T1, T2, ...V) R {
return func(t1 T1, t2 T2, v ...V) R {
return f(t1, t2, v)
}
}
// Unvariadic2 converts a function taking 2 parameters and a final variadic argument into a function with 2 parameters but a final slice argument
func Unvariadic2[T1, T2, V, R any](f func(T1, T2, ...V) R) func(T1, T2, []V) R {
return func(t1 T1, t2 T2, v []V) R {
return f(t1, t2, v...)
}
}
// Pipe3 takes an initial value t0 and successively applies 3 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Pipe3[T0, T1, T2, T3 any](t0 T0, f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3) T3 { func Pipe3[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, T0, T1, T2, T3 any](t0 T0, f1 F1, f2 F2, f3 F3) T3 {
t1 := f1(t0) t1 := f1(t0)
t2 := f2(t1) t2 := f2(t1)
t3 := f3(t2) t3 := f3(t2)
return t3 return t3
} }
// Flow3 creates a function that takes an initial value t0 and sucessively applies 3 functions where the input of a function is the return value of the previous function // Flow3 creates a function that takes an initial value t0 and successively applies 3 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Flow3[T0, T1, T2, T3 any](f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3) func(T0) T3 { func Flow3[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, T0, T1, T2, T3 any](f1 F1, f2 F2, f3 F3) func(T0) T3 {
return func(t0 T0) T3 { return func(t0 T0) T3 {
return Pipe3(t0, f1, f2, f3) return Pipe3(t0, f1, f2, f3)
} }
} }
// Nullary3 creates a parameter less function from a parameter less function and 2 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions // Nullary3 creates a parameter less function from a parameter less function and 2 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions
func Nullary3[T1, T2, T3 any](f1 func() T1, f2 func(T1) T2, f3 func(T2) T3) func() T3 { func Nullary3[F1 ~func() T1, F2 ~func(T1) T2, F3 ~func(T2) T3, T1, T2, T3 any](f1 F1, f2 F2, f3 F3) func() T3 {
return func() T3 { return func() T3 {
return Pipe2(f1(), f2, f3) return Pipe2(f1(), f2, f3)
} }
@@ -126,9 +174,23 @@ func Uncurry3[T0, T1, T2, T3 any](f func(T0) func(T1) func(T2) T3) func(T0, T1,
} }
} }
// Pipe4 takes an initial value t0 and sucessively applies 4 functions where the input of a function is the return value of the previous function // Variadic3 converts a function taking 3 parameters and a final slice into a function with 3 parameters but a final variadic argument
func Variadic3[T1, T2, T3, V, R any](f func(T1, T2, T3, []V) R) func(T1, T2, T3, ...V) R {
return func(t1 T1, t2 T2, t3 T3, v ...V) R {
return f(t1, t2, t3, v)
}
}
// Unvariadic3 converts a function taking 3 parameters and a final variadic argument into a function with 3 parameters but a final slice argument
func Unvariadic3[T1, T2, T3, V, R any](f func(T1, T2, T3, ...V) R) func(T1, T2, T3, []V) R {
return func(t1 T1, t2 T2, t3 T3, v []V) R {
return f(t1, t2, t3, v...)
}
}
// Pipe4 takes an initial value t0 and successively applies 4 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Pipe4[T0, T1, T2, T3, T4 any](t0 T0, f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4) T4 { func Pipe4[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, T0, T1, T2, T3, T4 any](t0 T0, f1 F1, f2 F2, f3 F3, f4 F4) T4 {
t1 := f1(t0) t1 := f1(t0)
t2 := f2(t1) t2 := f2(t1)
t3 := f3(t2) t3 := f3(t2)
@@ -136,16 +198,16 @@ func Pipe4[T0, T1, T2, T3, T4 any](t0 T0, f1 func(T0) T1, f2 func(T1) T2, f3 fun
return t4 return t4
} }
// Flow4 creates a function that takes an initial value t0 and sucessively applies 4 functions where the input of a function is the return value of the previous function // Flow4 creates a function that takes an initial value t0 and successively applies 4 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Flow4[T0, T1, T2, T3, T4 any](f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4) func(T0) T4 { func Flow4[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, T0, T1, T2, T3, T4 any](f1 F1, f2 F2, f3 F3, f4 F4) func(T0) T4 {
return func(t0 T0) T4 { return func(t0 T0) T4 {
return Pipe4(t0, f1, f2, f3, f4) return Pipe4(t0, f1, f2, f3, f4)
} }
} }
// Nullary4 creates a parameter less function from a parameter less function and 3 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions // Nullary4 creates a parameter less function from a parameter less function and 3 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions
func Nullary4[T1, T2, T3, T4 any](f1 func() T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4) func() T4 { func Nullary4[F1 ~func() T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, T1, T2, T3, T4 any](f1 F1, f2 F2, f3 F3, f4 F4) func() T4 {
return func() T4 { return func() T4 {
return Pipe3(f1(), f2, f3, f4) return Pipe3(f1(), f2, f3, f4)
} }
@@ -173,9 +235,23 @@ func Uncurry4[T0, T1, T2, T3, T4 any](f func(T0) func(T1) func(T2) func(T3) T4)
} }
} }
// Pipe5 takes an initial value t0 and sucessively applies 5 functions where the input of a function is the return value of the previous function // Variadic4 converts a function taking 4 parameters and a final slice into a function with 4 parameters but a final variadic argument
func Variadic4[T1, T2, T3, T4, V, R any](f func(T1, T2, T3, T4, []V) R) func(T1, T2, T3, T4, ...V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, v ...V) R {
return f(t1, t2, t3, t4, v)
}
}
// Unvariadic4 converts a function taking 4 parameters and a final variadic argument into a function with 4 parameters but a final slice argument
func Unvariadic4[T1, T2, T3, T4, V, R any](f func(T1, T2, T3, T4, ...V) R) func(T1, T2, T3, T4, []V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, v []V) R {
return f(t1, t2, t3, t4, v...)
}
}
// Pipe5 takes an initial value t0 and successively applies 5 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Pipe5[T0, T1, T2, T3, T4, T5 any](t0 T0, f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5) T5 { func Pipe5[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, T0, T1, T2, T3, T4, T5 any](t0 T0, f1 F1, f2 F2, f3 F3, f4 F4, f5 F5) T5 {
t1 := f1(t0) t1 := f1(t0)
t2 := f2(t1) t2 := f2(t1)
t3 := f3(t2) t3 := f3(t2)
@@ -184,16 +260,16 @@ func Pipe5[T0, T1, T2, T3, T4, T5 any](t0 T0, f1 func(T0) T1, f2 func(T1) T2, f3
return t5 return t5
} }
// Flow5 creates a function that takes an initial value t0 and sucessively applies 5 functions where the input of a function is the return value of the previous function // Flow5 creates a function that takes an initial value t0 and successively applies 5 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Flow5[T0, T1, T2, T3, T4, T5 any](f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5) func(T0) T5 { func Flow5[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, T0, T1, T2, T3, T4, T5 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5) func(T0) T5 {
return func(t0 T0) T5 { return func(t0 T0) T5 {
return Pipe5(t0, f1, f2, f3, f4, f5) return Pipe5(t0, f1, f2, f3, f4, f5)
} }
} }
// Nullary5 creates a parameter less function from a parameter less function and 4 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions // Nullary5 creates a parameter less function from a parameter less function and 4 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions
func Nullary5[T1, T2, T3, T4, T5 any](f1 func() T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5) func() T5 { func Nullary5[F1 ~func() T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, T1, T2, T3, T4, T5 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5) func() T5 {
return func() T5 { return func() T5 {
return Pipe4(f1(), f2, f3, f4, f5) return Pipe4(f1(), f2, f3, f4, f5)
} }
@@ -223,9 +299,23 @@ func Uncurry5[T0, T1, T2, T3, T4, T5 any](f func(T0) func(T1) func(T2) func(T3)
} }
} }
// Pipe6 takes an initial value t0 and sucessively applies 6 functions where the input of a function is the return value of the previous function // Variadic5 converts a function taking 5 parameters and a final slice into a function with 5 parameters but a final variadic argument
func Variadic5[T1, T2, T3, T4, T5, V, R any](f func(T1, T2, T3, T4, T5, []V) R) func(T1, T2, T3, T4, T5, ...V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, v ...V) R {
return f(t1, t2, t3, t4, t5, v)
}
}
// Unvariadic5 converts a function taking 5 parameters and a final variadic argument into a function with 5 parameters but a final slice argument
func Unvariadic5[T1, T2, T3, T4, T5, V, R any](f func(T1, T2, T3, T4, T5, ...V) R) func(T1, T2, T3, T4, T5, []V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, v []V) R {
return f(t1, t2, t3, t4, t5, v...)
}
}
// Pipe6 takes an initial value t0 and successively applies 6 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Pipe6[T0, T1, T2, T3, T4, T5, T6 any](t0 T0, f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6) T6 { func Pipe6[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, T0, T1, T2, T3, T4, T5, T6 any](t0 T0, f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6) T6 {
t1 := f1(t0) t1 := f1(t0)
t2 := f2(t1) t2 := f2(t1)
t3 := f3(t2) t3 := f3(t2)
@@ -235,16 +325,16 @@ func Pipe6[T0, T1, T2, T3, T4, T5, T6 any](t0 T0, f1 func(T0) T1, f2 func(T1) T2
return t6 return t6
} }
// Flow6 creates a function that takes an initial value t0 and sucessively applies 6 functions where the input of a function is the return value of the previous function // Flow6 creates a function that takes an initial value t0 and successively applies 6 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Flow6[T0, T1, T2, T3, T4, T5, T6 any](f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6) func(T0) T6 { func Flow6[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, T0, T1, T2, T3, T4, T5, T6 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6) func(T0) T6 {
return func(t0 T0) T6 { return func(t0 T0) T6 {
return Pipe6(t0, f1, f2, f3, f4, f5, f6) return Pipe6(t0, f1, f2, f3, f4, f5, f6)
} }
} }
// Nullary6 creates a parameter less function from a parameter less function and 5 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions // Nullary6 creates a parameter less function from a parameter less function and 5 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions
func Nullary6[T1, T2, T3, T4, T5, T6 any](f1 func() T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6) func() T6 { func Nullary6[F1 ~func() T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, T1, T2, T3, T4, T5, T6 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6) func() T6 {
return func() T6 { return func() T6 {
return Pipe5(f1(), f2, f3, f4, f5, f6) return Pipe5(f1(), f2, f3, f4, f5, f6)
} }
@@ -276,9 +366,23 @@ func Uncurry6[T0, T1, T2, T3, T4, T5, T6 any](f func(T0) func(T1) func(T2) func(
} }
} }
// Pipe7 takes an initial value t0 and sucessively applies 7 functions where the input of a function is the return value of the previous function // Variadic6 converts a function taking 6 parameters and a final slice into a function with 6 parameters but a final variadic argument
func Variadic6[T1, T2, T3, T4, T5, T6, V, R any](f func(T1, T2, T3, T4, T5, T6, []V) R) func(T1, T2, T3, T4, T5, T6, ...V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, v ...V) R {
return f(t1, t2, t3, t4, t5, t6, v)
}
}
// Unvariadic6 converts a function taking 6 parameters and a final variadic argument into a function with 6 parameters but a final slice argument
func Unvariadic6[T1, T2, T3, T4, T5, T6, V, R any](f func(T1, T2, T3, T4, T5, T6, ...V) R) func(T1, T2, T3, T4, T5, T6, []V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, v []V) R {
return f(t1, t2, t3, t4, t5, t6, v...)
}
}
// Pipe7 takes an initial value t0 and successively applies 7 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Pipe7[T0, T1, T2, T3, T4, T5, T6, T7 any](t0 T0, f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7) T7 { func Pipe7[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, T0, T1, T2, T3, T4, T5, T6, T7 any](t0 T0, f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7) T7 {
t1 := f1(t0) t1 := f1(t0)
t2 := f2(t1) t2 := f2(t1)
t3 := f3(t2) t3 := f3(t2)
@@ -289,16 +393,16 @@ func Pipe7[T0, T1, T2, T3, T4, T5, T6, T7 any](t0 T0, f1 func(T0) T1, f2 func(T1
return t7 return t7
} }
// Flow7 creates a function that takes an initial value t0 and sucessively applies 7 functions where the input of a function is the return value of the previous function // Flow7 creates a function that takes an initial value t0 and successively applies 7 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Flow7[T0, T1, T2, T3, T4, T5, T6, T7 any](f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7) func(T0) T7 { func Flow7[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, T0, T1, T2, T3, T4, T5, T6, T7 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7) func(T0) T7 {
return func(t0 T0) T7 { return func(t0 T0) T7 {
return Pipe7(t0, f1, f2, f3, f4, f5, f6, f7) return Pipe7(t0, f1, f2, f3, f4, f5, f6, f7)
} }
} }
// Nullary7 creates a parameter less function from a parameter less function and 6 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions // Nullary7 creates a parameter less function from a parameter less function and 6 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions
func Nullary7[T1, T2, T3, T4, T5, T6, T7 any](f1 func() T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7) func() T7 { func Nullary7[F1 ~func() T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, T1, T2, T3, T4, T5, T6, T7 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7) func() T7 {
return func() T7 { return func() T7 {
return Pipe6(f1(), f2, f3, f4, f5, f6, f7) return Pipe6(f1(), f2, f3, f4, f5, f6, f7)
} }
@@ -332,9 +436,23 @@ func Uncurry7[T0, T1, T2, T3, T4, T5, T6, T7 any](f func(T0) func(T1) func(T2) f
} }
} }
// Pipe8 takes an initial value t0 and sucessively applies 8 functions where the input of a function is the return value of the previous function // Variadic7 converts a function taking 7 parameters and a final slice into a function with 7 parameters but a final variadic argument
func Variadic7[T1, T2, T3, T4, T5, T6, T7, V, R any](f func(T1, T2, T3, T4, T5, T6, T7, []V) R) func(T1, T2, T3, T4, T5, T6, T7, ...V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, v ...V) R {
return f(t1, t2, t3, t4, t5, t6, t7, v)
}
}
// Unvariadic7 converts a function taking 7 parameters and a final variadic argument into a function with 7 parameters but a final slice argument
func Unvariadic7[T1, T2, T3, T4, T5, T6, T7, V, R any](f func(T1, T2, T3, T4, T5, T6, T7, ...V) R) func(T1, T2, T3, T4, T5, T6, T7, []V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, v []V) R {
return f(t1, t2, t3, t4, t5, t6, t7, v...)
}
}
// Pipe8 takes an initial value t0 and successively applies 8 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Pipe8[T0, T1, T2, T3, T4, T5, T6, T7, T8 any](t0 T0, f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8) T8 { func Pipe8[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, T0, T1, T2, T3, T4, T5, T6, T7, T8 any](t0 T0, f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8) T8 {
t1 := f1(t0) t1 := f1(t0)
t2 := f2(t1) t2 := f2(t1)
t3 := f3(t2) t3 := f3(t2)
@@ -346,16 +464,16 @@ func Pipe8[T0, T1, T2, T3, T4, T5, T6, T7, T8 any](t0 T0, f1 func(T0) T1, f2 fun
return t8 return t8
} }
// Flow8 creates a function that takes an initial value t0 and sucessively applies 8 functions where the input of a function is the return value of the previous function // Flow8 creates a function that takes an initial value t0 and successively applies 8 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Flow8[T0, T1, T2, T3, T4, T5, T6, T7, T8 any](f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8) func(T0) T8 { func Flow8[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, T0, T1, T2, T3, T4, T5, T6, T7, T8 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8) func(T0) T8 {
return func(t0 T0) T8 { return func(t0 T0) T8 {
return Pipe8(t0, f1, f2, f3, f4, f5, f6, f7, f8) return Pipe8(t0, f1, f2, f3, f4, f5, f6, f7, f8)
} }
} }
// Nullary8 creates a parameter less function from a parameter less function and 7 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions // Nullary8 creates a parameter less function from a parameter less function and 7 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions
func Nullary8[T1, T2, T3, T4, T5, T6, T7, T8 any](f1 func() T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8) func() T8 { func Nullary8[F1 ~func() T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, T1, T2, T3, T4, T5, T6, T7, T8 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8) func() T8 {
return func() T8 { return func() T8 {
return Pipe7(f1(), f2, f3, f4, f5, f6, f7, f8) return Pipe7(f1(), f2, f3, f4, f5, f6, f7, f8)
} }
@@ -391,9 +509,23 @@ func Uncurry8[T0, T1, T2, T3, T4, T5, T6, T7, T8 any](f func(T0) func(T1) func(T
} }
} }
// Pipe9 takes an initial value t0 and sucessively applies 9 functions where the input of a function is the return value of the previous function // Variadic8 converts a function taking 8 parameters and a final slice into a function with 8 parameters but a final variadic argument
func Variadic8[T1, T2, T3, T4, T5, T6, T7, T8, V, R any](f func(T1, T2, T3, T4, T5, T6, T7, T8, []V) R) func(T1, T2, T3, T4, T5, T6, T7, T8, ...V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8, v ...V) R {
return f(t1, t2, t3, t4, t5, t6, t7, t8, v)
}
}
// Unvariadic8 converts a function taking 8 parameters and a final variadic argument into a function with 8 parameters but a final slice argument
func Unvariadic8[T1, T2, T3, T4, T5, T6, T7, T8, V, R any](f func(T1, T2, T3, T4, T5, T6, T7, T8, ...V) R) func(T1, T2, T3, T4, T5, T6, T7, T8, []V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8, v []V) R {
return f(t1, t2, t3, t4, t5, t6, t7, t8, v...)
}
}
// Pipe9 takes an initial value t0 and successively applies 9 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Pipe9[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 any](t0 T0, f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9) T9 { func Pipe9[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 any](t0 T0, f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9) T9 {
t1 := f1(t0) t1 := f1(t0)
t2 := f2(t1) t2 := f2(t1)
t3 := f3(t2) t3 := f3(t2)
@@ -406,16 +538,16 @@ func Pipe9[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 any](t0 T0, f1 func(T0) T1, f2
return t9 return t9
} }
// Flow9 creates a function that takes an initial value t0 and sucessively applies 9 functions where the input of a function is the return value of the previous function // Flow9 creates a function that takes an initial value t0 and successively applies 9 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Flow9[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 any](f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9) func(T0) T9 { func Flow9[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9) func(T0) T9 {
return func(t0 T0) T9 { return func(t0 T0) T9 {
return Pipe9(t0, f1, f2, f3, f4, f5, f6, f7, f8, f9) return Pipe9(t0, f1, f2, f3, f4, f5, f6, f7, f8, f9)
} }
} }
// Nullary9 creates a parameter less function from a parameter less function and 8 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions // Nullary9 creates a parameter less function from a parameter less function and 8 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions
func Nullary9[T1, T2, T3, T4, T5, T6, T7, T8, T9 any](f1 func() T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9) func() T9 { func Nullary9[F1 ~func() T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, T1, T2, T3, T4, T5, T6, T7, T8, T9 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9) func() T9 {
return func() T9 { return func() T9 {
return Pipe8(f1(), f2, f3, f4, f5, f6, f7, f8, f9) return Pipe8(f1(), f2, f3, f4, f5, f6, f7, f8, f9)
} }
@@ -453,9 +585,23 @@ func Uncurry9[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 any](f func(T0) func(T1) fu
} }
} }
// Pipe10 takes an initial value t0 and sucessively applies 10 functions where the input of a function is the return value of the previous function // Variadic9 converts a function taking 9 parameters and a final slice into a function with 9 parameters but a final variadic argument
func Variadic9[T1, T2, T3, T4, T5, T6, T7, T8, T9, V, R any](f func(T1, T2, T3, T4, T5, T6, T7, T8, T9, []V) R) func(T1, T2, T3, T4, T5, T6, T7, T8, T9, ...V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8, t9 T9, v ...V) R {
return f(t1, t2, t3, t4, t5, t6, t7, t8, t9, v)
}
}
// Unvariadic9 converts a function taking 9 parameters and a final variadic argument into a function with 9 parameters but a final slice argument
func Unvariadic9[T1, T2, T3, T4, T5, T6, T7, T8, T9, V, R any](f func(T1, T2, T3, T4, T5, T6, T7, T8, T9, ...V) R) func(T1, T2, T3, T4, T5, T6, T7, T8, T9, []V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8, t9 T9, v []V) R {
return f(t1, t2, t3, t4, t5, t6, t7, t8, t9, v...)
}
}
// Pipe10 takes an initial value t0 and successively applies 10 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Pipe10[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 any](t0 T0, f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9, f10 func(T9) T10) T10 { func Pipe10[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, F10 ~func(T9) T10, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 any](t0 T0, f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10) T10 {
t1 := f1(t0) t1 := f1(t0)
t2 := f2(t1) t2 := f2(t1)
t3 := f3(t2) t3 := f3(t2)
@@ -469,16 +615,16 @@ func Pipe10[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 any](t0 T0, f1 func(T0)
return t10 return t10
} }
// Flow10 creates a function that takes an initial value t0 and sucessively applies 10 functions where the input of a function is the return value of the previous function // Flow10 creates a function that takes an initial value t0 and successively applies 10 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Flow10[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 any](f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9, f10 func(T9) T10) func(T0) T10 { func Flow10[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, F10 ~func(T9) T10, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10) func(T0) T10 {
return func(t0 T0) T10 { return func(t0 T0) T10 {
return Pipe10(t0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10) return Pipe10(t0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10)
} }
} }
// Nullary10 creates a parameter less function from a parameter less function and 9 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions // Nullary10 creates a parameter less function from a parameter less function and 9 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions
func Nullary10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 any](f1 func() T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9, f10 func(T9) T10) func() T10 { func Nullary10[F1 ~func() T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, F10 ~func(T9) T10, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10) func() T10 {
return func() T10 { return func() T10 {
return Pipe9(f1(), f2, f3, f4, f5, f6, f7, f8, f9, f10) return Pipe9(f1(), f2, f3, f4, f5, f6, f7, f8, f9, f10)
} }
@@ -518,9 +664,23 @@ func Uncurry10[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 any](f func(T0) func(
} }
} }
// Pipe11 takes an initial value t0 and sucessively applies 11 functions where the input of a function is the return value of the previous function // Variadic10 converts a function taking 10 parameters and a final slice into a function with 10 parameters but a final variadic argument
func Variadic10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, V, R any](f func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, []V) R) func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, ...V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8, t9 T9, t10 T10, v ...V) R {
return f(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, v)
}
}
// Unvariadic10 converts a function taking 10 parameters and a final variadic argument into a function with 10 parameters but a final slice argument
func Unvariadic10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, V, R any](f func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, ...V) R) func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, []V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8, t9 T9, t10 T10, v []V) R {
return f(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, v...)
}
}
// Pipe11 takes an initial value t0 and successively applies 11 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Pipe11[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11 any](t0 T0, f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9, f10 func(T9) T10, f11 func(T10) T11) T11 { func Pipe11[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, F10 ~func(T9) T10, F11 ~func(T10) T11, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11 any](t0 T0, f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10, f11 F11) T11 {
t1 := f1(t0) t1 := f1(t0)
t2 := f2(t1) t2 := f2(t1)
t3 := f3(t2) t3 := f3(t2)
@@ -535,16 +695,16 @@ func Pipe11[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11 any](t0 T0, f1 func
return t11 return t11
} }
// Flow11 creates a function that takes an initial value t0 and sucessively applies 11 functions where the input of a function is the return value of the previous function // Flow11 creates a function that takes an initial value t0 and successively applies 11 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Flow11[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11 any](f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9, f10 func(T9) T10, f11 func(T10) T11) func(T0) T11 { func Flow11[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, F10 ~func(T9) T10, F11 ~func(T10) T11, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10, f11 F11) func(T0) T11 {
return func(t0 T0) T11 { return func(t0 T0) T11 {
return Pipe11(t0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11) return Pipe11(t0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11)
} }
} }
// Nullary11 creates a parameter less function from a parameter less function and 10 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions // Nullary11 creates a parameter less function from a parameter less function and 10 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions
func Nullary11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11 any](f1 func() T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9, f10 func(T9) T10, f11 func(T10) T11) func() T11 { func Nullary11[F1 ~func() T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, F10 ~func(T9) T10, F11 ~func(T10) T11, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10, f11 F11) func() T11 {
return func() T11 { return func() T11 {
return Pipe10(f1(), f2, f3, f4, f5, f6, f7, f8, f9, f10, f11) return Pipe10(f1(), f2, f3, f4, f5, f6, f7, f8, f9, f10, f11)
} }
@@ -586,9 +746,23 @@ func Uncurry11[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11 any](f func(T0)
} }
} }
// Pipe12 takes an initial value t0 and sucessively applies 12 functions where the input of a function is the return value of the previous function // Variadic11 converts a function taking 11 parameters and a final slice into a function with 11 parameters but a final variadic argument
func Variadic11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, V, R any](f func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, []V) R) func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, ...V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8, t9 T9, t10 T10, t11 T11, v ...V) R {
return f(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, v)
}
}
// Unvariadic11 converts a function taking 11 parameters and a final variadic argument into a function with 11 parameters but a final slice argument
func Unvariadic11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, V, R any](f func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, ...V) R) func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, []V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8, t9 T9, t10 T10, t11 T11, v []V) R {
return f(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, v...)
}
}
// Pipe12 takes an initial value t0 and successively applies 12 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Pipe12[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12 any](t0 T0, f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9, f10 func(T9) T10, f11 func(T10) T11, f12 func(T11) T12) T12 { func Pipe12[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, F10 ~func(T9) T10, F11 ~func(T10) T11, F12 ~func(T11) T12, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12 any](t0 T0, f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10, f11 F11, f12 F12) T12 {
t1 := f1(t0) t1 := f1(t0)
t2 := f2(t1) t2 := f2(t1)
t3 := f3(t2) t3 := f3(t2)
@@ -604,16 +778,16 @@ func Pipe12[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12 any](t0 T0, f1
return t12 return t12
} }
// Flow12 creates a function that takes an initial value t0 and sucessively applies 12 functions where the input of a function is the return value of the previous function // Flow12 creates a function that takes an initial value t0 and successively applies 12 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Flow12[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12 any](f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9, f10 func(T9) T10, f11 func(T10) T11, f12 func(T11) T12) func(T0) T12 { func Flow12[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, F10 ~func(T9) T10, F11 ~func(T10) T11, F12 ~func(T11) T12, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10, f11 F11, f12 F12) func(T0) T12 {
return func(t0 T0) T12 { return func(t0 T0) T12 {
return Pipe12(t0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12) return Pipe12(t0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12)
} }
} }
// Nullary12 creates a parameter less function from a parameter less function and 11 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions // Nullary12 creates a parameter less function from a parameter less function and 11 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions
func Nullary12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12 any](f1 func() T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9, f10 func(T9) T10, f11 func(T10) T11, f12 func(T11) T12) func() T12 { func Nullary12[F1 ~func() T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, F10 ~func(T9) T10, F11 ~func(T10) T11, F12 ~func(T11) T12, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10, f11 F11, f12 F12) func() T12 {
return func() T12 { return func() T12 {
return Pipe11(f1(), f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12) return Pipe11(f1(), f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12)
} }
@@ -657,9 +831,23 @@ func Uncurry12[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12 any](f func
} }
} }
// Pipe13 takes an initial value t0 and sucessively applies 13 functions where the input of a function is the return value of the previous function // Variadic12 converts a function taking 12 parameters and a final slice into a function with 12 parameters but a final variadic argument
func Variadic12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, V, R any](f func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, []V) R) func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, ...V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8, t9 T9, t10 T10, t11 T11, t12 T12, v ...V) R {
return f(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, v)
}
}
// Unvariadic12 converts a function taking 12 parameters and a final variadic argument into a function with 12 parameters but a final slice argument
func Unvariadic12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, V, R any](f func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, ...V) R) func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, []V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8, t9 T9, t10 T10, t11 T11, t12 T12, v []V) R {
return f(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, v...)
}
}
// Pipe13 takes an initial value t0 and successively applies 13 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Pipe13[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13 any](t0 T0, f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9, f10 func(T9) T10, f11 func(T10) T11, f12 func(T11) T12, f13 func(T12) T13) T13 { func Pipe13[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, F10 ~func(T9) T10, F11 ~func(T10) T11, F12 ~func(T11) T12, F13 ~func(T12) T13, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13 any](t0 T0, f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10, f11 F11, f12 F12, f13 F13) T13 {
t1 := f1(t0) t1 := f1(t0)
t2 := f2(t1) t2 := f2(t1)
t3 := f3(t2) t3 := f3(t2)
@@ -676,16 +864,16 @@ func Pipe13[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13 any](t0 T
return t13 return t13
} }
// Flow13 creates a function that takes an initial value t0 and sucessively applies 13 functions where the input of a function is the return value of the previous function // Flow13 creates a function that takes an initial value t0 and successively applies 13 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Flow13[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13 any](f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9, f10 func(T9) T10, f11 func(T10) T11, f12 func(T11) T12, f13 func(T12) T13) func(T0) T13 { func Flow13[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, F10 ~func(T9) T10, F11 ~func(T10) T11, F12 ~func(T11) T12, F13 ~func(T12) T13, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10, f11 F11, f12 F12, f13 F13) func(T0) T13 {
return func(t0 T0) T13 { return func(t0 T0) T13 {
return Pipe13(t0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13) return Pipe13(t0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13)
} }
} }
// Nullary13 creates a parameter less function from a parameter less function and 12 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions // Nullary13 creates a parameter less function from a parameter less function and 12 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions
func Nullary13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13 any](f1 func() T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9, f10 func(T9) T10, f11 func(T10) T11, f12 func(T11) T12, f13 func(T12) T13) func() T13 { func Nullary13[F1 ~func() T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, F10 ~func(T9) T10, F11 ~func(T10) T11, F12 ~func(T11) T12, F13 ~func(T12) T13, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10, f11 F11, f12 F12, f13 F13) func() T13 {
return func() T13 { return func() T13 {
return Pipe12(f1(), f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13) return Pipe12(f1(), f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13)
} }
@@ -731,9 +919,23 @@ func Uncurry13[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13 any](f
} }
} }
// Pipe14 takes an initial value t0 and sucessively applies 14 functions where the input of a function is the return value of the previous function // Variadic13 converts a function taking 13 parameters and a final slice into a function with 13 parameters but a final variadic argument
func Variadic13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, V, R any](f func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, []V) R) func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, ...V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8, t9 T9, t10 T10, t11 T11, t12 T12, t13 T13, v ...V) R {
return f(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, v)
}
}
// Unvariadic13 converts a function taking 13 parameters and a final variadic argument into a function with 13 parameters but a final slice argument
func Unvariadic13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, V, R any](f func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, ...V) R) func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, []V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8, t9 T9, t10 T10, t11 T11, t12 T12, t13 T13, v []V) R {
return f(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, v...)
}
}
// Pipe14 takes an initial value t0 and successively applies 14 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Pipe14[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14 any](t0 T0, f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9, f10 func(T9) T10, f11 func(T10) T11, f12 func(T11) T12, f13 func(T12) T13, f14 func(T13) T14) T14 { func Pipe14[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, F10 ~func(T9) T10, F11 ~func(T10) T11, F12 ~func(T11) T12, F13 ~func(T12) T13, F14 ~func(T13) T14, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14 any](t0 T0, f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10, f11 F11, f12 F12, f13 F13, f14 F14) T14 {
t1 := f1(t0) t1 := f1(t0)
t2 := f2(t1) t2 := f2(t1)
t3 := f3(t2) t3 := f3(t2)
@@ -751,16 +953,16 @@ func Pipe14[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14 any]
return t14 return t14
} }
// Flow14 creates a function that takes an initial value t0 and sucessively applies 14 functions where the input of a function is the return value of the previous function // Flow14 creates a function that takes an initial value t0 and successively applies 14 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Flow14[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14 any](f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9, f10 func(T9) T10, f11 func(T10) T11, f12 func(T11) T12, f13 func(T12) T13, f14 func(T13) T14) func(T0) T14 { func Flow14[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, F10 ~func(T9) T10, F11 ~func(T10) T11, F12 ~func(T11) T12, F13 ~func(T12) T13, F14 ~func(T13) T14, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10, f11 F11, f12 F12, f13 F13, f14 F14) func(T0) T14 {
return func(t0 T0) T14 { return func(t0 T0) T14 {
return Pipe14(t0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14) return Pipe14(t0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14)
} }
} }
// Nullary14 creates a parameter less function from a parameter less function and 13 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions // Nullary14 creates a parameter less function from a parameter less function and 13 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions
func Nullary14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14 any](f1 func() T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9, f10 func(T9) T10, f11 func(T10) T11, f12 func(T11) T12, f13 func(T12) T13, f14 func(T13) T14) func() T14 { func Nullary14[F1 ~func() T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, F10 ~func(T9) T10, F11 ~func(T10) T11, F12 ~func(T11) T12, F13 ~func(T12) T13, F14 ~func(T13) T14, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10, f11 F11, f12 F12, f13 F13, f14 F14) func() T14 {
return func() T14 { return func() T14 {
return Pipe13(f1(), f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14) return Pipe13(f1(), f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14)
} }
@@ -808,9 +1010,23 @@ func Uncurry14[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14 a
} }
} }
// Pipe15 takes an initial value t0 and sucessively applies 15 functions where the input of a function is the return value of the previous function // Variadic14 converts a function taking 14 parameters and a final slice into a function with 14 parameters but a final variadic argument
func Variadic14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, V, R any](f func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, []V) R) func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, ...V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8, t9 T9, t10 T10, t11 T11, t12 T12, t13 T13, t14 T14, v ...V) R {
return f(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, v)
}
}
// Unvariadic14 converts a function taking 14 parameters and a final variadic argument into a function with 14 parameters but a final slice argument
func Unvariadic14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, V, R any](f func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, ...V) R) func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, []V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8, t9 T9, t10 T10, t11 T11, t12 T12, t13 T13, t14 T14, v []V) R {
return f(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, v...)
}
}
// Pipe15 takes an initial value t0 and successively applies 15 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Pipe15[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15 any](t0 T0, f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9, f10 func(T9) T10, f11 func(T10) T11, f12 func(T11) T12, f13 func(T12) T13, f14 func(T13) T14, f15 func(T14) T15) T15 { func Pipe15[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, F10 ~func(T9) T10, F11 ~func(T10) T11, F12 ~func(T11) T12, F13 ~func(T12) T13, F14 ~func(T13) T14, F15 ~func(T14) T15, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15 any](t0 T0, f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10, f11 F11, f12 F12, f13 F13, f14 F14, f15 F15) T15 {
t1 := f1(t0) t1 := f1(t0)
t2 := f2(t1) t2 := f2(t1)
t3 := f3(t2) t3 := f3(t2)
@@ -829,16 +1045,16 @@ func Pipe15[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15
return t15 return t15
} }
// Flow15 creates a function that takes an initial value t0 and sucessively applies 15 functions where the input of a function is the return value of the previous function // Flow15 creates a function that takes an initial value t0 and successively applies 15 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Flow15[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15 any](f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9, f10 func(T9) T10, f11 func(T10) T11, f12 func(T11) T12, f13 func(T12) T13, f14 func(T13) T14, f15 func(T14) T15) func(T0) T15 { func Flow15[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, F10 ~func(T9) T10, F11 ~func(T10) T11, F12 ~func(T11) T12, F13 ~func(T12) T13, F14 ~func(T13) T14, F15 ~func(T14) T15, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10, f11 F11, f12 F12, f13 F13, f14 F14, f15 F15) func(T0) T15 {
return func(t0 T0) T15 { return func(t0 T0) T15 {
return Pipe15(t0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15) return Pipe15(t0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15)
} }
} }
// Nullary15 creates a parameter less function from a parameter less function and 14 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions // Nullary15 creates a parameter less function from a parameter less function and 14 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions
func Nullary15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15 any](f1 func() T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9, f10 func(T9) T10, f11 func(T10) T11, f12 func(T11) T12, f13 func(T12) T13, f14 func(T13) T14, f15 func(T14) T15) func() T15 { func Nullary15[F1 ~func() T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, F10 ~func(T9) T10, F11 ~func(T10) T11, F12 ~func(T11) T12, F13 ~func(T12) T13, F14 ~func(T13) T14, F15 ~func(T14) T15, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10, f11 F11, f12 F12, f13 F13, f14 F14, f15 F15) func() T15 {
return func() T15 { return func() T15 {
return Pipe14(f1(), f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15) return Pipe14(f1(), f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15)
} }
@@ -888,9 +1104,23 @@ func Uncurry15[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
} }
} }
// Pipe16 takes an initial value t0 and sucessively applies 16 functions where the input of a function is the return value of the previous function // Variadic15 converts a function taking 15 parameters and a final slice into a function with 15 parameters but a final variadic argument
func Variadic15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, V, R any](f func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, []V) R) func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, ...V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8, t9 T9, t10 T10, t11 T11, t12 T12, t13 T13, t14 T14, t15 T15, v ...V) R {
return f(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, v)
}
}
// Unvariadic15 converts a function taking 15 parameters and a final variadic argument into a function with 15 parameters but a final slice argument
func Unvariadic15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, V, R any](f func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, ...V) R) func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, []V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8, t9 T9, t10 T10, t11 T11, t12 T12, t13 T13, t14 T14, t15 T15, v []V) R {
return f(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, v...)
}
}
// Pipe16 takes an initial value t0 and successively applies 16 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Pipe16[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16 any](t0 T0, f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9, f10 func(T9) T10, f11 func(T10) T11, f12 func(T11) T12, f13 func(T12) T13, f14 func(T13) T14, f15 func(T14) T15, f16 func(T15) T16) T16 { func Pipe16[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, F10 ~func(T9) T10, F11 ~func(T10) T11, F12 ~func(T11) T12, F13 ~func(T12) T13, F14 ~func(T13) T14, F15 ~func(T14) T15, F16 ~func(T15) T16, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16 any](t0 T0, f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10, f11 F11, f12 F12, f13 F13, f14 F14, f15 F15, f16 F16) T16 {
t1 := f1(t0) t1 := f1(t0)
t2 := f2(t1) t2 := f2(t1)
t3 := f3(t2) t3 := f3(t2)
@@ -910,16 +1140,16 @@ func Pipe16[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15
return t16 return t16
} }
// Flow16 creates a function that takes an initial value t0 and sucessively applies 16 functions where the input of a function is the return value of the previous function // Flow16 creates a function that takes an initial value t0 and successively applies 16 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Flow16[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16 any](f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9, f10 func(T9) T10, f11 func(T10) T11, f12 func(T11) T12, f13 func(T12) T13, f14 func(T13) T14, f15 func(T14) T15, f16 func(T15) T16) func(T0) T16 { func Flow16[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, F10 ~func(T9) T10, F11 ~func(T10) T11, F12 ~func(T11) T12, F13 ~func(T12) T13, F14 ~func(T13) T14, F15 ~func(T14) T15, F16 ~func(T15) T16, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10, f11 F11, f12 F12, f13 F13, f14 F14, f15 F15, f16 F16) func(T0) T16 {
return func(t0 T0) T16 { return func(t0 T0) T16 {
return Pipe16(t0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16) return Pipe16(t0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16)
} }
} }
// Nullary16 creates a parameter less function from a parameter less function and 15 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions // Nullary16 creates a parameter less function from a parameter less function and 15 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions
func Nullary16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16 any](f1 func() T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9, f10 func(T9) T10, f11 func(T10) T11, f12 func(T11) T12, f13 func(T12) T13, f14 func(T13) T14, f15 func(T14) T15, f16 func(T15) T16) func() T16 { func Nullary16[F1 ~func() T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, F10 ~func(T9) T10, F11 ~func(T10) T11, F12 ~func(T11) T12, F13 ~func(T12) T13, F14 ~func(T13) T14, F15 ~func(T14) T15, F16 ~func(T15) T16, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10, f11 F11, f12 F12, f13 F13, f14 F14, f15 F15, f16 F16) func() T16 {
return func() T16 { return func() T16 {
return Pipe15(f1(), f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16) return Pipe15(f1(), f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16)
} }
@@ -971,9 +1201,23 @@ func Uncurry16[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
} }
} }
// Pipe17 takes an initial value t0 and sucessively applies 17 functions where the input of a function is the return value of the previous function // Variadic16 converts a function taking 16 parameters and a final slice into a function with 16 parameters but a final variadic argument
func Variadic16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, V, R any](f func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, []V) R) func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, ...V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8, t9 T9, t10 T10, t11 T11, t12 T12, t13 T13, t14 T14, t15 T15, t16 T16, v ...V) R {
return f(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, v)
}
}
// Unvariadic16 converts a function taking 16 parameters and a final variadic argument into a function with 16 parameters but a final slice argument
func Unvariadic16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, V, R any](f func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, ...V) R) func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, []V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8, t9 T9, t10 T10, t11 T11, t12 T12, t13 T13, t14 T14, t15 T15, t16 T16, v []V) R {
return f(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, v...)
}
}
// Pipe17 takes an initial value t0 and successively applies 17 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Pipe17[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17 any](t0 T0, f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9, f10 func(T9) T10, f11 func(T10) T11, f12 func(T11) T12, f13 func(T12) T13, f14 func(T13) T14, f15 func(T14) T15, f16 func(T15) T16, f17 func(T16) T17) T17 { func Pipe17[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, F10 ~func(T9) T10, F11 ~func(T10) T11, F12 ~func(T11) T12, F13 ~func(T12) T13, F14 ~func(T13) T14, F15 ~func(T14) T15, F16 ~func(T15) T16, F17 ~func(T16) T17, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17 any](t0 T0, f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10, f11 F11, f12 F12, f13 F13, f14 F14, f15 F15, f16 F16, f17 F17) T17 {
t1 := f1(t0) t1 := f1(t0)
t2 := f2(t1) t2 := f2(t1)
t3 := f3(t2) t3 := f3(t2)
@@ -994,16 +1238,16 @@ func Pipe17[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15
return t17 return t17
} }
// Flow17 creates a function that takes an initial value t0 and sucessively applies 17 functions where the input of a function is the return value of the previous function // Flow17 creates a function that takes an initial value t0 and successively applies 17 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Flow17[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17 any](f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9, f10 func(T9) T10, f11 func(T10) T11, f12 func(T11) T12, f13 func(T12) T13, f14 func(T13) T14, f15 func(T14) T15, f16 func(T15) T16, f17 func(T16) T17) func(T0) T17 { func Flow17[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, F10 ~func(T9) T10, F11 ~func(T10) T11, F12 ~func(T11) T12, F13 ~func(T12) T13, F14 ~func(T13) T14, F15 ~func(T14) T15, F16 ~func(T15) T16, F17 ~func(T16) T17, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10, f11 F11, f12 F12, f13 F13, f14 F14, f15 F15, f16 F16, f17 F17) func(T0) T17 {
return func(t0 T0) T17 { return func(t0 T0) T17 {
return Pipe17(t0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17) return Pipe17(t0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17)
} }
} }
// Nullary17 creates a parameter less function from a parameter less function and 16 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions // Nullary17 creates a parameter less function from a parameter less function and 16 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions
func Nullary17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17 any](f1 func() T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9, f10 func(T9) T10, f11 func(T10) T11, f12 func(T11) T12, f13 func(T12) T13, f14 func(T13) T14, f15 func(T14) T15, f16 func(T15) T16, f17 func(T16) T17) func() T17 { func Nullary17[F1 ~func() T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, F10 ~func(T9) T10, F11 ~func(T10) T11, F12 ~func(T11) T12, F13 ~func(T12) T13, F14 ~func(T13) T14, F15 ~func(T14) T15, F16 ~func(T15) T16, F17 ~func(T16) T17, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10, f11 F11, f12 F12, f13 F13, f14 F14, f15 F15, f16 F16, f17 F17) func() T17 {
return func() T17 { return func() T17 {
return Pipe16(f1(), f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17) return Pipe16(f1(), f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17)
} }
@@ -1057,9 +1301,23 @@ func Uncurry17[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
} }
} }
// Pipe18 takes an initial value t0 and sucessively applies 18 functions where the input of a function is the return value of the previous function // Variadic17 converts a function taking 17 parameters and a final slice into a function with 17 parameters but a final variadic argument
func Variadic17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, V, R any](f func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, []V) R) func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, ...V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8, t9 T9, t10 T10, t11 T11, t12 T12, t13 T13, t14 T14, t15 T15, t16 T16, t17 T17, v ...V) R {
return f(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, v)
}
}
// Unvariadic17 converts a function taking 17 parameters and a final variadic argument into a function with 17 parameters but a final slice argument
func Unvariadic17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, V, R any](f func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, ...V) R) func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, []V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8, t9 T9, t10 T10, t11 T11, t12 T12, t13 T13, t14 T14, t15 T15, t16 T16, t17 T17, v []V) R {
return f(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, v...)
}
}
// Pipe18 takes an initial value t0 and successively applies 18 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Pipe18[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18 any](t0 T0, f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9, f10 func(T9) T10, f11 func(T10) T11, f12 func(T11) T12, f13 func(T12) T13, f14 func(T13) T14, f15 func(T14) T15, f16 func(T15) T16, f17 func(T16) T17, f18 func(T17) T18) T18 { func Pipe18[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, F10 ~func(T9) T10, F11 ~func(T10) T11, F12 ~func(T11) T12, F13 ~func(T12) T13, F14 ~func(T13) T14, F15 ~func(T14) T15, F16 ~func(T15) T16, F17 ~func(T16) T17, F18 ~func(T17) T18, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18 any](t0 T0, f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10, f11 F11, f12 F12, f13 F13, f14 F14, f15 F15, f16 F16, f17 F17, f18 F18) T18 {
t1 := f1(t0) t1 := f1(t0)
t2 := f2(t1) t2 := f2(t1)
t3 := f3(t2) t3 := f3(t2)
@@ -1081,16 +1339,16 @@ func Pipe18[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15
return t18 return t18
} }
// Flow18 creates a function that takes an initial value t0 and sucessively applies 18 functions where the input of a function is the return value of the previous function // Flow18 creates a function that takes an initial value t0 and successively applies 18 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Flow18[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18 any](f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9, f10 func(T9) T10, f11 func(T10) T11, f12 func(T11) T12, f13 func(T12) T13, f14 func(T13) T14, f15 func(T14) T15, f16 func(T15) T16, f17 func(T16) T17, f18 func(T17) T18) func(T0) T18 { func Flow18[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, F10 ~func(T9) T10, F11 ~func(T10) T11, F12 ~func(T11) T12, F13 ~func(T12) T13, F14 ~func(T13) T14, F15 ~func(T14) T15, F16 ~func(T15) T16, F17 ~func(T16) T17, F18 ~func(T17) T18, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10, f11 F11, f12 F12, f13 F13, f14 F14, f15 F15, f16 F16, f17 F17, f18 F18) func(T0) T18 {
return func(t0 T0) T18 { return func(t0 T0) T18 {
return Pipe18(t0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18) return Pipe18(t0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18)
} }
} }
// Nullary18 creates a parameter less function from a parameter less function and 17 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions // Nullary18 creates a parameter less function from a parameter less function and 17 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions
func Nullary18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18 any](f1 func() T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9, f10 func(T9) T10, f11 func(T10) T11, f12 func(T11) T12, f13 func(T12) T13, f14 func(T13) T14, f15 func(T14) T15, f16 func(T15) T16, f17 func(T16) T17, f18 func(T17) T18) func() T18 { func Nullary18[F1 ~func() T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, F10 ~func(T9) T10, F11 ~func(T10) T11, F12 ~func(T11) T12, F13 ~func(T12) T13, F14 ~func(T13) T14, F15 ~func(T14) T15, F16 ~func(T15) T16, F17 ~func(T16) T17, F18 ~func(T17) T18, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10, f11 F11, f12 F12, f13 F13, f14 F14, f15 F15, f16 F16, f17 F17, f18 F18) func() T18 {
return func() T18 { return func() T18 {
return Pipe17(f1(), f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18) return Pipe17(f1(), f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18)
} }
@@ -1146,9 +1404,23 @@ func Uncurry18[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
} }
} }
// Pipe19 takes an initial value t0 and sucessively applies 19 functions where the input of a function is the return value of the previous function // Variadic18 converts a function taking 18 parameters and a final slice into a function with 18 parameters but a final variadic argument
func Variadic18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, V, R any](f func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, []V) R) func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, ...V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8, t9 T9, t10 T10, t11 T11, t12 T12, t13 T13, t14 T14, t15 T15, t16 T16, t17 T17, t18 T18, v ...V) R {
return f(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, v)
}
}
// Unvariadic18 converts a function taking 18 parameters and a final variadic argument into a function with 18 parameters but a final slice argument
func Unvariadic18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, V, R any](f func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, ...V) R) func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, []V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8, t9 T9, t10 T10, t11 T11, t12 T12, t13 T13, t14 T14, t15 T15, t16 T16, t17 T17, t18 T18, v []V) R {
return f(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, v...)
}
}
// Pipe19 takes an initial value t0 and successively applies 19 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Pipe19[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19 any](t0 T0, f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9, f10 func(T9) T10, f11 func(T10) T11, f12 func(T11) T12, f13 func(T12) T13, f14 func(T13) T14, f15 func(T14) T15, f16 func(T15) T16, f17 func(T16) T17, f18 func(T17) T18, f19 func(T18) T19) T19 { func Pipe19[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, F10 ~func(T9) T10, F11 ~func(T10) T11, F12 ~func(T11) T12, F13 ~func(T12) T13, F14 ~func(T13) T14, F15 ~func(T14) T15, F16 ~func(T15) T16, F17 ~func(T16) T17, F18 ~func(T17) T18, F19 ~func(T18) T19, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19 any](t0 T0, f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10, f11 F11, f12 F12, f13 F13, f14 F14, f15 F15, f16 F16, f17 F17, f18 F18, f19 F19) T19 {
t1 := f1(t0) t1 := f1(t0)
t2 := f2(t1) t2 := f2(t1)
t3 := f3(t2) t3 := f3(t2)
@@ -1171,16 +1443,16 @@ func Pipe19[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15
return t19 return t19
} }
// Flow19 creates a function that takes an initial value t0 and sucessively applies 19 functions where the input of a function is the return value of the previous function // Flow19 creates a function that takes an initial value t0 and successively applies 19 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Flow19[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19 any](f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9, f10 func(T9) T10, f11 func(T10) T11, f12 func(T11) T12, f13 func(T12) T13, f14 func(T13) T14, f15 func(T14) T15, f16 func(T15) T16, f17 func(T16) T17, f18 func(T17) T18, f19 func(T18) T19) func(T0) T19 { func Flow19[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, F10 ~func(T9) T10, F11 ~func(T10) T11, F12 ~func(T11) T12, F13 ~func(T12) T13, F14 ~func(T13) T14, F15 ~func(T14) T15, F16 ~func(T15) T16, F17 ~func(T16) T17, F18 ~func(T17) T18, F19 ~func(T18) T19, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10, f11 F11, f12 F12, f13 F13, f14 F14, f15 F15, f16 F16, f17 F17, f18 F18, f19 F19) func(T0) T19 {
return func(t0 T0) T19 { return func(t0 T0) T19 {
return Pipe19(t0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19) return Pipe19(t0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19)
} }
} }
// Nullary19 creates a parameter less function from a parameter less function and 18 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions // Nullary19 creates a parameter less function from a parameter less function and 18 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions
func Nullary19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19 any](f1 func() T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9, f10 func(T9) T10, f11 func(T10) T11, f12 func(T11) T12, f13 func(T12) T13, f14 func(T13) T14, f15 func(T14) T15, f16 func(T15) T16, f17 func(T16) T17, f18 func(T17) T18, f19 func(T18) T19) func() T19 { func Nullary19[F1 ~func() T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, F10 ~func(T9) T10, F11 ~func(T10) T11, F12 ~func(T11) T12, F13 ~func(T12) T13, F14 ~func(T13) T14, F15 ~func(T14) T15, F16 ~func(T15) T16, F17 ~func(T16) T17, F18 ~func(T17) T18, F19 ~func(T18) T19, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10, f11 F11, f12 F12, f13 F13, f14 F14, f15 F15, f16 F16, f17 F17, f18 F18, f19 F19) func() T19 {
return func() T19 { return func() T19 {
return Pipe18(f1(), f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19) return Pipe18(f1(), f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19)
} }
@@ -1238,9 +1510,23 @@ func Uncurry19[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
} }
} }
// Pipe20 takes an initial value t0 and sucessively applies 20 functions where the input of a function is the return value of the previous function // Variadic19 converts a function taking 19 parameters and a final slice into a function with 19 parameters but a final variadic argument
func Variadic19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, V, R any](f func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, []V) R) func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, ...V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8, t9 T9, t10 T10, t11 T11, t12 T12, t13 T13, t14 T14, t15 T15, t16 T16, t17 T17, t18 T18, t19 T19, v ...V) R {
return f(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, v)
}
}
// Unvariadic19 converts a function taking 19 parameters and a final variadic argument into a function with 19 parameters but a final slice argument
func Unvariadic19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, V, R any](f func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, ...V) R) func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, []V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8, t9 T9, t10 T10, t11 T11, t12 T12, t13 T13, t14 T14, t15 T15, t16 T16, t17 T17, t18 T18, t19 T19, v []V) R {
return f(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, v...)
}
}
// Pipe20 takes an initial value t0 and successively applies 20 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Pipe20[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20 any](t0 T0, f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9, f10 func(T9) T10, f11 func(T10) T11, f12 func(T11) T12, f13 func(T12) T13, f14 func(T13) T14, f15 func(T14) T15, f16 func(T15) T16, f17 func(T16) T17, f18 func(T17) T18, f19 func(T18) T19, f20 func(T19) T20) T20 { func Pipe20[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, F10 ~func(T9) T10, F11 ~func(T10) T11, F12 ~func(T11) T12, F13 ~func(T12) T13, F14 ~func(T13) T14, F15 ~func(T14) T15, F16 ~func(T15) T16, F17 ~func(T16) T17, F18 ~func(T17) T18, F19 ~func(T18) T19, F20 ~func(T19) T20, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20 any](t0 T0, f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10, f11 F11, f12 F12, f13 F13, f14 F14, f15 F15, f16 F16, f17 F17, f18 F18, f19 F19, f20 F20) T20 {
t1 := f1(t0) t1 := f1(t0)
t2 := f2(t1) t2 := f2(t1)
t3 := f3(t2) t3 := f3(t2)
@@ -1264,16 +1550,16 @@ func Pipe20[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15
return t20 return t20
} }
// Flow20 creates a function that takes an initial value t0 and sucessively applies 20 functions where the input of a function is the return value of the previous function // Flow20 creates a function that takes an initial value t0 and successively applies 20 functions where the input of a function is the return value of the previous function
// The final return value is the result of the last function application // The final return value is the result of the last function application
func Flow20[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20 any](f1 func(T0) T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9, f10 func(T9) T10, f11 func(T10) T11, f12 func(T11) T12, f13 func(T12) T13, f14 func(T13) T14, f15 func(T14) T15, f16 func(T15) T16, f17 func(T16) T17, f18 func(T17) T18, f19 func(T18) T19, f20 func(T19) T20) func(T0) T20 { func Flow20[F1 ~func(T0) T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, F10 ~func(T9) T10, F11 ~func(T10) T11, F12 ~func(T11) T12, F13 ~func(T12) T13, F14 ~func(T13) T14, F15 ~func(T14) T15, F16 ~func(T15) T16, F17 ~func(T16) T17, F18 ~func(T17) T18, F19 ~func(T18) T19, F20 ~func(T19) T20, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10, f11 F11, f12 F12, f13 F13, f14 F14, f15 F15, f16 F16, f17 F17, f18 F18, f19 F19, f20 F20) func(T0) T20 {
return func(t0 T0) T20 { return func(t0 T0) T20 {
return Pipe20(t0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20) return Pipe20(t0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20)
} }
} }
// Nullary20 creates a parameter less function from a parameter less function and 19 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions // Nullary20 creates a parameter less function from a parameter less function and 19 functions. When executed the first parameter less function gets executed and then the result is piped through the remaining functions
func Nullary20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20 any](f1 func() T1, f2 func(T1) T2, f3 func(T2) T3, f4 func(T3) T4, f5 func(T4) T5, f6 func(T5) T6, f7 func(T6) T7, f8 func(T7) T8, f9 func(T8) T9, f10 func(T9) T10, f11 func(T10) T11, f12 func(T11) T12, f13 func(T12) T13, f14 func(T13) T14, f15 func(T14) T15, f16 func(T15) T16, f17 func(T16) T17, f18 func(T17) T18, f19 func(T18) T19, f20 func(T19) T20) func() T20 { func Nullary20[F1 ~func() T1, F2 ~func(T1) T2, F3 ~func(T2) T3, F4 ~func(T3) T4, F5 ~func(T4) T5, F6 ~func(T5) T6, F7 ~func(T6) T7, F8 ~func(T7) T8, F9 ~func(T8) T9, F10 ~func(T9) T10, F11 ~func(T10) T11, F12 ~func(T11) T12, F13 ~func(T12) T13, F14 ~func(T13) T14, F15 ~func(T14) T15, F16 ~func(T15) T16, F17 ~func(T16) T17, F18 ~func(T17) T18, F19 ~func(T18) T19, F20 ~func(T19) T20, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20 any](f1 F1, f2 F2, f3 F3, f4 F4, f5 F5, f6 F6, f7 F7, f8 F8, f9 F9, f10 F10, f11 F11, f12 F12, f13 F13, f14 F14, f15 F15, f16 F16, f17 F17, f18 F18, f19 F19, f20 F20) func() T20 {
return func() T20 { return func() T20 {
return Pipe19(f1(), f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20) return Pipe19(f1(), f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20)
} }
@@ -1332,3 +1618,17 @@ func Uncurry20[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
return f(t0)(t1)(t2)(t3)(t4)(t5)(t6)(t7)(t8)(t9)(t10)(t11)(t12)(t13)(t14)(t15)(t16)(t17)(t18)(t19) return f(t0)(t1)(t2)(t3)(t4)(t5)(t6)(t7)(t8)(t9)(t10)(t11)(t12)(t13)(t14)(t15)(t16)(t17)(t18)(t19)
} }
} }
// Variadic20 converts a function taking 20 parameters and a final slice into a function with 20 parameters but a final variadic argument
func Variadic20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, V, R any](f func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, []V) R) func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, ...V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8, t9 T9, t10 T10, t11 T11, t12 T12, t13 T13, t14 T14, t15 T15, t16 T16, t17 T17, t18 T18, t19 T19, t20 T20, v ...V) R {
return f(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, v)
}
}
// Unvariadic20 converts a function taking 20 parameters and a final variadic argument into a function with 20 parameters but a final slice argument
func Unvariadic20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, V, R any](f func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, ...V) R) func(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, []V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8, t9 T9, t10 T10, t11 T11, t12 T12, t13 T13, t14 T14, t15 T15, t16 T16, t17 T17, t18 T18, t19 T19, t20 T20, v []V) R {
return f(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, v...)
}
}

View File

@@ -1,61 +0,0 @@
package function
func Variadic0[V, R any](f func([]V) R) func(...V) R {
return func(v ...V) R {
return f(v)
}
}
func Variadic1[T1, V, R any](f func(T1, []V) R) func(T1, ...V) R {
return func(t1 T1, v ...V) R {
return f(t1, v)
}
}
func Variadic2[T1, T2, V, R any](f func(T1, T2, []V) R) func(T1, T2, ...V) R {
return func(t1 T1, t2 T2, v ...V) R {
return f(t1, t2, v)
}
}
func Variadic3[T1, T2, T3, V, R any](f func(T1, T2, T3, []V) R) func(T1, T2, T3, ...V) R {
return func(t1 T1, t2 T2, t3 T3, v ...V) R {
return f(t1, t2, t3, v)
}
}
func Variadic4[T1, T2, T3, T4, V, R any](f func(T1, T2, T3, T4, []V) R) func(T1, T2, T3, T4, ...V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, v ...V) R {
return f(t1, t2, t3, t4, v)
}
}
func Unvariadic0[V, R any](f func(...V) R) func([]V) R {
return func(v []V) R {
return f(v...)
}
}
func Unvariadic1[T1, V, R any](f func(T1, ...V) R) func(T1, []V) R {
return func(t1 T1, v []V) R {
return f(t1, v...)
}
}
func Unvariadic2[T1, T2, V, R any](f func(T1, T2, ...V) R) func(T1, T2, []V) R {
return func(t1 T1, t2 T2, v []V) R {
return f(t1, t2, v...)
}
}
func Unvariadic3[T1, T2, T3, V, R any](f func(T1, T2, T3, ...V) R) func(T1, T2, T3, []V) R {
return func(t1 T1, t2 T2, t3 T3, v []V) R {
return f(t1, t2, t3, v...)
}
}
func Unvariadic4[T1, T2, T3, T4, V, R any](f func(T1, T2, T3, T4, ...V) R) func(T1, T2, T3, T4, []V) R {
return func(t1 T1, t2 T2, t3 T3, t4 T4, v []V) R {
return f(t1, t2, t3, t4, v...)
}
}

7
go.mod
View File

@@ -2,15 +2,16 @@ module github.com/ibm/fp-go
go 1.20 go 1.20
require github.com/stretchr/testify v1.8.4 require (
github.com/stretchr/testify v1.8.4
github.com/urfave/cli/v2 v2.25.7
)
require ( require (
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/urfave/cli/v2 v2.25.7 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
) )

9
go.sum
View File

@@ -1,25 +1,18 @@
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs=
github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@@ -14,9 +14,7 @@ func main() {
app := &C.App{ app := &C.App{
Name: "fp-go", Name: "fp-go",
Usage: "Code generation for fp-go", Usage: "Code generation for fp-go",
Commands: []*C.Command{ Commands: cli.Commands(),
cli.PipeCommand(),
},
} }
if err := app.Run(os.Args); err != nil { if err := app.Run(os.Args); err != nil {

View File

@@ -1 +1,3 @@
package option package option
//go:generate go run .. option --count 10 --filename optionize.go

View File

@@ -20,24 +20,8 @@ func FromNillable[A any](a *A) Option[*A] {
return fromPredicate(a, F.IsNonNil[A]) return fromPredicate(a, F.IsNonNil[A])
} }
func fromValidation[A, B any](a A, f func(A) (B, bool)) Option[B] {
b, ok := f(a)
if ok {
return Some(b)
}
return None[B]()
}
func fromValidation0[A any](f func() (A, bool)) Option[A] {
a, ok := f()
if ok {
return Some(a)
}
return None[A]()
}
func FromValidation[A, B any](f func(A) (B, bool)) func(A) Option[B] { func FromValidation[A, B any](f func(A) (B, bool)) func(A) Option[B] {
return F.Bind2nd(fromValidation[A, B], f) return Optionize1(f)
} }
// MonadAp is the applicative functor of Option // MonadAp is the applicative functor of Option
@@ -141,65 +125,3 @@ func Reduce[A, B any](f func(B, A) B, initial B) func(Option[A]) B {
func Filter[A any](pred func(A) bool) func(Option[A]) Option[A] { func Filter[A any](pred func(A) bool) func(Option[A]) Option[A] {
return Fold(None[A], F.Ternary(pred, Of[A], F.Ignore1[A](None[A]))) return Fold(None[A], F.Ternary(pred, Of[A], F.Ignore1[A](None[A])))
} }
func Optionize0[R any](f func() (R, bool)) func() Option[R] {
return func() Option[R] {
return fromValidation0(f)
}
}
func Optionize1[T1, R any](f func(T1) (R, bool)) func(T1) Option[R] {
return func(t1 T1) Option[R] {
return fromValidation0(func() (R, bool) {
return f(t1)
})
}
}
func Unoptionize1[T1, R any](f func(T1) Option[R]) func(T1) (R, bool) {
return func(t1 T1) (R, bool) {
return Unwrap(f(t1))
}
}
func Optionize2[T1, T2, R any](f func(t1 T1, t2 T2) (R, bool)) func(t1 T1, t2 T2) Option[R] {
return func(t1 T1, t2 T2) Option[R] {
return fromValidation0(func() (R, bool) {
return f(t1, t2)
})
}
}
func Unoptionize2[T1, T2, R any](f func(T1, T2) Option[R]) func(T1, T2) (R, bool) {
return func(t1 T1, t2 T2) (R, bool) {
return Unwrap(f(t1, t2))
}
}
func Optionize3[T1, T2, T3, R any](f func(t1 T1, t2 T2, t3 T3) (R, bool)) func(t1 T1, t2 T2, t3 T3) Option[R] {
return func(t1 T1, t2 T2, t3 T3) Option[R] {
return fromValidation0(func() (R, bool) {
return f(t1, t2, t3)
})
}
}
func Unoptionize3[T1, T2, T3, R any](f func(T1, T2, T3) Option[R]) func(T1, T2, T3) (R, bool) {
return func(t1 T1, t2 T2, t3 T3) (R, bool) {
return Unwrap(f(t1, t2, t3))
}
}
func Optionize4[T1, T2, T3, T4, R any](f func(t1 T1, t2 T2, t3 T3, t4 T4) (R, bool)) func(t1 T1, t2 T2, t3 T3, t4 T4) Option[R] {
return func(t1 T1, t2 T2, t3 T3, t4 T4) Option[R] {
return fromValidation0(func() (R, bool) {
return f(t1, t2, t3, t4)
})
}
}
func Unoptionize4[T1, T2, T3, T4, R any](f func(T1, T2, T3, T4) Option[R]) func(T1, T2, T3, T4) (R, bool) {
return func(t1 T1, t2 T2, t3 T3, t4 T4) (R, bool) {
return Unwrap(f(t1, t2, t3, t4))
}
}

188
option/optionize.go Normal file
View File

@@ -0,0 +1,188 @@
// Code generated by go generate; DO NOT EDIT.
// This file was generated by robots at
// 2023-07-13 16:10:33.8303184 +0200 CEST m=+0.008901701
package option
// optionize converts a nullary function to an option
func optionize[R any](f func() (R, bool)) Option[R] {
if r, ok := f(); ok {
return Some(r)
}
return None[R]()
}
// Optionize0 converts a function with 0 parameters returning a tuple of a return value R and a boolean into a function with 0 parameters returning an Option[R]
func Optionize0[F ~func() (R, bool), R any](f F) func() Option[R] {
return func() Option[R] {
return optionize(func() (R, bool) {
return f()
})
}
}
// Unoptionize0 converts a function with 0 parameters returning a tuple of a return value R and a boolean into a function with 0 parameters returning an Option[R]
func Unoptionize0[F ~func() Option[R], R any](f F) func() (R, bool) {
return func() (R, bool) {
return Unwrap(f())
}
}
// Optionize1 converts a function with 1 parameters returning a tuple of a return value R and a boolean into a function with 1 parameters returning an Option[R]
func Optionize1[F ~func(T0) (R, bool), T0, R any](f F) func(T0) Option[R] {
return func(t0 T0) Option[R] {
return optionize(func() (R, bool) {
return f(t0)
})
}
}
// Unoptionize1 converts a function with 1 parameters returning a tuple of a return value R and a boolean into a function with 1 parameters returning an Option[R]
func Unoptionize1[F ~func(T0) Option[R], T0, R any](f F) func(T0) (R, bool) {
return func(t0 T0) (R, bool) {
return Unwrap(f(t0))
}
}
// Optionize2 converts a function with 2 parameters returning a tuple of a return value R and a boolean into a function with 2 parameters returning an Option[R]
func Optionize2[F ~func(T0, T1) (R, bool), T0, T1, R any](f F) func(T0, T1) Option[R] {
return func(t0 T0, t1 T1) Option[R] {
return optionize(func() (R, bool) {
return f(t0, t1)
})
}
}
// Unoptionize2 converts a function with 2 parameters returning a tuple of a return value R and a boolean into a function with 2 parameters returning an Option[R]
func Unoptionize2[F ~func(T0, T1) Option[R], T0, T1, R any](f F) func(T0, T1) (R, bool) {
return func(t0 T0, t1 T1) (R, bool) {
return Unwrap(f(t0, t1))
}
}
// Optionize3 converts a function with 3 parameters returning a tuple of a return value R and a boolean into a function with 3 parameters returning an Option[R]
func Optionize3[F ~func(T0, T1, T2) (R, bool), T0, T1, T2, R any](f F) func(T0, T1, T2) Option[R] {
return func(t0 T0, t1 T1, t2 T2) Option[R] {
return optionize(func() (R, bool) {
return f(t0, t1, t2)
})
}
}
// Unoptionize3 converts a function with 3 parameters returning a tuple of a return value R and a boolean into a function with 3 parameters returning an Option[R]
func Unoptionize3[F ~func(T0, T1, T2) Option[R], T0, T1, T2, R any](f F) func(T0, T1, T2) (R, bool) {
return func(t0 T0, t1 T1, t2 T2) (R, bool) {
return Unwrap(f(t0, t1, t2))
}
}
// Optionize4 converts a function with 4 parameters returning a tuple of a return value R and a boolean into a function with 4 parameters returning an Option[R]
func Optionize4[F ~func(T0, T1, T2, T3) (R, bool), T0, T1, T2, T3, R any](f F) func(T0, T1, T2, T3) Option[R] {
return func(t0 T0, t1 T1, t2 T2, t3 T3) Option[R] {
return optionize(func() (R, bool) {
return f(t0, t1, t2, t3)
})
}
}
// Unoptionize4 converts a function with 4 parameters returning a tuple of a return value R and a boolean into a function with 4 parameters returning an Option[R]
func Unoptionize4[F ~func(T0, T1, T2, T3) Option[R], T0, T1, T2, T3, R any](f F) func(T0, T1, T2, T3) (R, bool) {
return func(t0 T0, t1 T1, t2 T2, t3 T3) (R, bool) {
return Unwrap(f(t0, t1, t2, t3))
}
}
// Optionize5 converts a function with 5 parameters returning a tuple of a return value R and a boolean into a function with 5 parameters returning an Option[R]
func Optionize5[F ~func(T0, T1, T2, T3, T4) (R, bool), T0, T1, T2, T3, T4, R any](f F) func(T0, T1, T2, T3, T4) Option[R] {
return func(t0 T0, t1 T1, t2 T2, t3 T3, t4 T4) Option[R] {
return optionize(func() (R, bool) {
return f(t0, t1, t2, t3, t4)
})
}
}
// Unoptionize5 converts a function with 5 parameters returning a tuple of a return value R and a boolean into a function with 5 parameters returning an Option[R]
func Unoptionize5[F ~func(T0, T1, T2, T3, T4) Option[R], T0, T1, T2, T3, T4, R any](f F) func(T0, T1, T2, T3, T4) (R, bool) {
return func(t0 T0, t1 T1, t2 T2, t3 T3, t4 T4) (R, bool) {
return Unwrap(f(t0, t1, t2, t3, t4))
}
}
// Optionize6 converts a function with 6 parameters returning a tuple of a return value R and a boolean into a function with 6 parameters returning an Option[R]
func Optionize6[F ~func(T0, T1, T2, T3, T4, T5) (R, bool), T0, T1, T2, T3, T4, T5, R any](f F) func(T0, T1, T2, T3, T4, T5) Option[R] {
return func(t0 T0, t1 T1, t2 T2, t3 T3, t4 T4, t5 T5) Option[R] {
return optionize(func() (R, bool) {
return f(t0, t1, t2, t3, t4, t5)
})
}
}
// Unoptionize6 converts a function with 6 parameters returning a tuple of a return value R and a boolean into a function with 6 parameters returning an Option[R]
func Unoptionize6[F ~func(T0, T1, T2, T3, T4, T5) Option[R], T0, T1, T2, T3, T4, T5, R any](f F) func(T0, T1, T2, T3, T4, T5) (R, bool) {
return func(t0 T0, t1 T1, t2 T2, t3 T3, t4 T4, t5 T5) (R, bool) {
return Unwrap(f(t0, t1, t2, t3, t4, t5))
}
}
// Optionize7 converts a function with 7 parameters returning a tuple of a return value R and a boolean into a function with 7 parameters returning an Option[R]
func Optionize7[F ~func(T0, T1, T2, T3, T4, T5, T6) (R, bool), T0, T1, T2, T3, T4, T5, T6, R any](f F) func(T0, T1, T2, T3, T4, T5, T6) Option[R] {
return func(t0 T0, t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6) Option[R] {
return optionize(func() (R, bool) {
return f(t0, t1, t2, t3, t4, t5, t6)
})
}
}
// Unoptionize7 converts a function with 7 parameters returning a tuple of a return value R and a boolean into a function with 7 parameters returning an Option[R]
func Unoptionize7[F ~func(T0, T1, T2, T3, T4, T5, T6) Option[R], T0, T1, T2, T3, T4, T5, T6, R any](f F) func(T0, T1, T2, T3, T4, T5, T6) (R, bool) {
return func(t0 T0, t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6) (R, bool) {
return Unwrap(f(t0, t1, t2, t3, t4, t5, t6))
}
}
// Optionize8 converts a function with 8 parameters returning a tuple of a return value R and a boolean into a function with 8 parameters returning an Option[R]
func Optionize8[F ~func(T0, T1, T2, T3, T4, T5, T6, T7) (R, bool), T0, T1, T2, T3, T4, T5, T6, T7, R any](f F) func(T0, T1, T2, T3, T4, T5, T6, T7) Option[R] {
return func(t0 T0, t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7) Option[R] {
return optionize(func() (R, bool) {
return f(t0, t1, t2, t3, t4, t5, t6, t7)
})
}
}
// Unoptionize8 converts a function with 8 parameters returning a tuple of a return value R and a boolean into a function with 8 parameters returning an Option[R]
func Unoptionize8[F ~func(T0, T1, T2, T3, T4, T5, T6, T7) Option[R], T0, T1, T2, T3, T4, T5, T6, T7, R any](f F) func(T0, T1, T2, T3, T4, T5, T6, T7) (R, bool) {
return func(t0 T0, t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7) (R, bool) {
return Unwrap(f(t0, t1, t2, t3, t4, t5, t6, t7))
}
}
// Optionize9 converts a function with 9 parameters returning a tuple of a return value R and a boolean into a function with 9 parameters returning an Option[R]
func Optionize9[F ~func(T0, T1, T2, T3, T4, T5, T6, T7, T8) (R, bool), T0, T1, T2, T3, T4, T5, T6, T7, T8, R any](f F) func(T0, T1, T2, T3, T4, T5, T6, T7, T8) Option[R] {
return func(t0 T0, t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8) Option[R] {
return optionize(func() (R, bool) {
return f(t0, t1, t2, t3, t4, t5, t6, t7, t8)
})
}
}
// Unoptionize9 converts a function with 9 parameters returning a tuple of a return value R and a boolean into a function with 9 parameters returning an Option[R]
func Unoptionize9[F ~func(T0, T1, T2, T3, T4, T5, T6, T7, T8) Option[R], T0, T1, T2, T3, T4, T5, T6, T7, T8, R any](f F) func(T0, T1, T2, T3, T4, T5, T6, T7, T8) (R, bool) {
return func(t0 T0, t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8) (R, bool) {
return Unwrap(f(t0, t1, t2, t3, t4, t5, t6, t7, t8))
}
}
// Optionize10 converts a function with 10 parameters returning a tuple of a return value R and a boolean into a function with 10 parameters returning an Option[R]
func Optionize10[F ~func(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9) (R, bool), T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, R any](f F) func(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9) Option[R] {
return func(t0 T0, t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8, t9 T9) Option[R] {
return optionize(func() (R, bool) {
return f(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9)
})
}
}
// Unoptionize10 converts a function with 10 parameters returning a tuple of a return value R and a boolean into a function with 10 parameters returning an Option[R]
func Unoptionize10[F ~func(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9) Option[R], T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, R any](f F) func(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9) (R, bool) {
return func(t0 T0, t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, t6 T6, t7 T7, t8 T8, t9 T9) (R, bool) {
return Unwrap(f(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9))
}
}

View File

@@ -1,12 +1,19 @@
package option package option
import (
F "github.com/ibm/fp-go/function"
)
func toType[T any](a any) (T, bool) { func toType[T any](a any) (T, bool) {
b, ok := a.(T) b, ok := a.(T)
return b, ok return b, ok
} }
func ToType[T any](src any) Option[T] { func ToType[T any](src any) Option[T] {
return fromValidation(src, toType[T]) return F.Pipe1(
src,
Optionize1(toType[T]),
)
} }
func ToAny[T any](src T) Option[any] { func ToAny[T any](src T) Option[any] {