1
0
mirror of https://github.com/IBM/fp-go.git synced 2025-11-25 22:21:49 +02:00
Files
fp-go/internal/eq/eq.go

20 lines
420 B
Go
Raw Normal View History

package eq
import (
EQ "github.com/IBM/fp-go/eq"
F "github.com/IBM/fp-go/function"
)
// Eq implements an equals predicate on the basis of `map` and `ap`
func Eq[HKTA, HKTABOOL, HKTBOOL, A any](
fmap func(HKTA, func(A) func(A) bool) HKTABOOL,
fap func(HKTABOOL, HKTA) HKTBOOL,
e EQ.Eq[A],
) func(l, r HKTA) HKTBOOL {
c := F.Curry2(e.Equals)
return func(fl, fr HKTA) HKTBOOL {
return fap(fmap(fl, c), fr)
}
}