1
0
mirror of https://github.com/IBM/fp-go.git synced 2025-11-29 22:38:29 +02:00
Files
fp-go/semigroup/apply.go
Dr. Carsten Leue c07df5c771 initial checkin
Signed-off-by: Dr. Carsten Leue <carsten.leue@de.ibm.com>
2023-07-07 22:31:06 +02:00

24 lines
391 B
Go

package semigroup
import (
F "github.com/ibm/fp-go/function"
)
/*
*
HKTA = HKT<A>
HKTFA = HKT<func(A)A>
*/
func ApplySemigroup[A, HKTA, HKTFA any](
_map func(HKTA, func(A) func(A) A) HKTFA,
_ap func(HKTFA, HKTA) HKTA,
s Semigroup[A],
) Semigroup[HKTA] {
cb := F.Curry2(s.Concat)
return MakeSemigroup(func(first HKTA, second HKTA) HKTA {
return _ap(_map(first, cb), second)
})
}