diff --git a/either/either.go b/either/either.go index 006b301..992ef6d 100644 --- a/either/either.go +++ b/either/either.go @@ -33,7 +33,7 @@ func Of[E, A any](value A) Either[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]) } diff --git a/either/either_test.go b/either/either_test.go index a413598..7f50a21 100644 --- a/either/either_test.go +++ b/either/either_test.go @@ -71,7 +71,6 @@ func TestReduce(t *testing.T) { assert.Equal(t, "foo", F.Pipe1(Left[string, string]("bar"), Reduce[string](s.Concat, "foo"))) } - func TestAp(t *testing.T) { f := S.Size @@ -120,3 +119,10 @@ func TestStringer(t *testing.T) { var s fmt.Stringer = e 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) +}