mirror of
https://github.com/IBM/fp-go.git
synced 2025-06-25 00:36:54 +02:00
21 lines
476 B
Go
21 lines
476 B
Go
![]() |
package generic
|
||
|
|
||
|
import (
|
||
|
EQ "github.com/ibm/fp-go/eq"
|
||
|
G "github.com/ibm/fp-go/internal/eq"
|
||
|
)
|
||
|
|
||
|
// Eq implements the equals predicate for values contained in the IO monad
|
||
|
func Eq[GA ~func() A, A any](e EQ.Eq[A]) EQ.Eq[GA] {
|
||
|
// comparator for the monad
|
||
|
eq := G.Eq(
|
||
|
MonadMap[GA, func() func(A) bool, A, func(A) bool],
|
||
|
MonadAp[GA, func() bool, func() func(A) bool, A, bool],
|
||
|
e,
|
||
|
)
|
||
|
// eagerly execute
|
||
|
return EQ.FromEquals(func(l, r GA) bool {
|
||
|
return eq(l, r)()
|
||
|
})
|
||
|
}
|