Skip to content

Commit

Permalink
correct the generic type for FromIO
Browse files Browse the repository at this point in the history
  • Loading branch information
francistm committed Mar 5, 2024
1 parent 9aa2ae0 commit 3b2abe6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion either/either.go
Original file line number Diff line number Diff line change
Expand Up @@ -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])
}

Expand Down
8 changes: 7 additions & 1 deletion either/either_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
}

0 comments on commit 3b2abe6

Please sign in to comment.