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

fix: introduce stateless iterator

Signed-off-by: Dr. Carsten Leue <carsten.leue@de.ibm.com>
This commit is contained in:
Dr. Carsten Leue
2023-07-24 16:43:07 +02:00
parent 8c58e8d760
commit 1713de0c3e
51 changed files with 2076 additions and 25 deletions

View File

@@ -16,6 +16,7 @@
package generic
import (
"fmt"
"log"
Logging "github.com/IBM/fp-go/logging"
@@ -39,3 +40,11 @@ func Logf[GA ~func() any, A any](prefix string) func(A) GA {
})
}
}
func Printf[GA ~func() any, A any](prefix string) func(A) GA {
return func(a A) GA {
return FromImpure[GA](func() {
fmt.Printf(prefix, a)
})
}
}

View File

@@ -31,3 +31,9 @@ func Logger[A any](loggers ...*log.Logger) func(string) func(A) IO[any] {
func Logf[A any](prefix string) func(A) IO[any] {
return G.Logf[IO[any], A](prefix)
}
// Printf constructs a printer function that can be used with ChainXXXIOK
// the string prefix contains the format string for the log value
func Printf[A any](prefix string) func(A) IO[any] {
return G.Printf[IO[any], A](prefix)
}