1
0
mirror of https://github.com/IBM/fp-go.git synced 2025-08-10 22:31:32 +02:00

fix: consistent endomorphism

Signed-off-by: Dr. Carsten Leue <carsten.leue@de.ibm.com>
This commit is contained in:
Dr. Carsten Leue
2023-12-17 13:24:05 +01:00
parent 5fcd0b1595
commit e82575fe08
3 changed files with 27 additions and 11 deletions

View File

@@ -29,15 +29,11 @@ func Of[ENDO ~func(A) A, F ~func(A) A, A any](f F) ENDO {
}
func Identity[ENDO ~func(A) A, A any]() ENDO {
return func(a A) A {
return a
}
return Of[ENDO](F.Identity[A])
}
func Compose[ENDO ~func(A) A, A any](f1, f2 ENDO) ENDO {
return func(a A) A {
return F.Pipe2(a, f1, f2)
}
return Of[ENDO](F.Flow2(f1, f2))
}
// Semigroup for the Endomorphism where the `concat` operation is the usual function composition.