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

fix: initial release

Signed-off-by: Dr. Carsten Leue <carsten.leue@de.ibm.com>
This commit is contained in:
Dr. Carsten Leue
2023-07-17 18:03:21 +02:00
parent 69c2fe1118
commit 2efe4f64c5
18 changed files with 890 additions and 115 deletions

View File

@@ -25,48 +25,7 @@ func generateEitherSequenceTuple(f *os.File, i int) {
}
func generateEitherSequenceT(f *os.File, i int) {
tuple := tupleType(i)
fmt.Fprintf(f, "\n// SequenceT%d converts %d parameters of [Either[E, T]] into an [Either] of a [Tuple%d].\n", i, i, i)
fmt.Fprintf(f, "func SequenceT%d[E", i)
for j := 0; j < i; j++ {
fmt.Fprintf(f, ", T%d", j+1)
}
fmt.Fprintf(f, " any](")
for j := 0; j < i; j++ {
if j > 0 {
fmt.Fprintf(f, ", ")
}
fmt.Fprintf(f, "t%d Either[E, T%d]", j+1, j+1)
}
fmt.Fprintf(f, ") Either[E, %s] {\n", tuple)
fmt.Fprintf(f, " return A.SequenceT%d(\n", i)
// map
fmt.Fprintf(f, " Map[E, T1,")
for j := 1; j < i; j++ {
fmt.Fprintf(f, " func(T%d)", j+1)
}
fmt.Fprintf(f, " %s],\n", tuple)
// applicatives
for j := 1; j < i; j++ {
fmt.Fprintf(f, " Ap[")
for k := j + 1; k < i; k++ {
if k > j+1 {
fmt.Fprintf(f, " ")
}
fmt.Fprintf(f, "func(T%d)", k+1)
}
if j < i-1 {
fmt.Fprintf(f, " ")
}
fmt.Fprintf(f, "%s, E, T%d],\n", tuple, j+1)
}
for j := 0; j < i; j++ {
fmt.Fprintf(f, " t%d,\n", j+1)
}
fmt.Fprintf(f, " )\n")
fmt.Fprintf(f, "}\n")
generateSequenceT1(eitherHKT("E"), "E")(f, i)
}
func generateUneitherize(f *os.File, i int) {