mirror of
https://github.com/IBM/fp-go.git
synced 2025-08-10 22:31:32 +02:00
correct the generic type for FromIO (#104)
Signed-off-by: francis <francis.tm@me.com>
This commit is contained in:
@@ -33,7 +33,7 @@ func Of[E, A any](value A) Either[E, A] {
|
|||||||
return F.Pipe1(value, Right[E, A])
|
return F.Pipe1(value, Right[E, A])
|
||||||
}
|
}
|
||||||
|
|
||||||
func FromIO[E, IO ~func() A, A any](f IO) Either[E, A] {
|
func FromIO[E any, IO ~func() A, A any](f IO) Either[E, A] {
|
||||||
return F.Pipe1(f(), Right[E, A])
|
return F.Pipe1(f(), Right[E, A])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -71,7 +71,6 @@ func TestReduce(t *testing.T) {
|
|||||||
assert.Equal(t, "foo", F.Pipe1(Left[string, string]("bar"), Reduce[string](s.Concat, "foo")))
|
assert.Equal(t, "foo", F.Pipe1(Left[string, string]("bar"), Reduce[string](s.Concat, "foo")))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAp(t *testing.T) {
|
func TestAp(t *testing.T) {
|
||||||
f := S.Size
|
f := S.Size
|
||||||
|
|
||||||
@@ -120,3 +119,10 @@ func TestStringer(t *testing.T) {
|
|||||||
var s fmt.Stringer = e
|
var s fmt.Stringer = e
|
||||||
assert.Equal(t, exp, s.String())
|
assert.Equal(t, exp, s.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestFromIO(t *testing.T) {
|
||||||
|
f := func() string { return "abc" }
|
||||||
|
e := FromIO[error](f)
|
||||||
|
|
||||||
|
assert.Equal(t, Right[error]("abc"), e)
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user