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:
@@ -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
|
||||
})
|
||||
}
|
||||
|
||||
|
@@ -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)() })
|
||||
}
|
||||
|
Reference in New Issue
Block a user