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

fix: refactor either type (#102)

Signed-off-by: Dr. Carsten Leue <carsten.leue@de.ibm.com>
This commit is contained in:
Carsten Leue
2024-02-07 11:03:20 +01:00
committed by GitHub
parent 7daf65effc
commit 8150ae2a68
18 changed files with 59 additions and 58 deletions

View File

@@ -25,6 +25,11 @@ import (
T "github.com/IBM/fp-go/tuple"
)
var (
// undefined represents an undefined value
undefined = struct{}{}
)
// type IO[A any] = func() A
func MakeIO[GA ~func() A, A any](f func() A) GA {
@@ -43,7 +48,7 @@ func FromIO[GA ~func() A, A any](a GA) GA {
func FromImpure[GA ~func() any, IMP ~func()](f IMP) GA {
return MakeIO[GA](func() any {
f()
return nil
return undefined
})
}

View File

@@ -27,7 +27,7 @@ func TestLogger(t *testing.T) {
lio := l("out")
assert.Equal(t, nil, lio(10)())
assert.NotPanics(t, func() { lio(10)() })
}
func TestLogf(t *testing.T) {
@@ -36,5 +36,5 @@ func TestLogf(t *testing.T) {
lio := l("Value is %d")
assert.Equal(t, nil, lio(10)())
assert.NotPanics(t, func() { lio(10)() })
}