1
0
mirror of https://github.com/IBM/fp-go.git synced 2025-07-15 01:24:23 +02:00

fix: build break

Signed-off-by: Dr. Carsten Leue <carsten.leue@de.ibm.com>
This commit is contained in:
Dr. Carsten Leue
2023-08-10 13:14:48 +02:00
parent d9b2804a7e
commit d9dda4cfa5
2 changed files with 8 additions and 3 deletions

View File

@ -21,18 +21,18 @@ import (
func UnionSemigroup[N ~map[K]V, K comparable, V any](s S.Semigroup[V]) S.Semigroup[N] { func UnionSemigroup[N ~map[K]V, K comparable, V any](s S.Semigroup[V]) S.Semigroup[N] {
return S.MakeSemigroup(func(first N, second N) N { return S.MakeSemigroup(func(first N, second N) N {
return union(s, first, second) return union[N, K, V](S.ToMagma(s), first, second)
}) })
} }
func UnionLastSemigroup[N ~map[K]V, K comparable, V any]() S.Semigroup[N] { func UnionLastSemigroup[N ~map[K]V, K comparable, V any]() S.Semigroup[N] {
return S.MakeSemigroup(func(first N, second N) N { return S.MakeSemigroup(func(first N, second N) N {
return unionLast(first, second) return unionLast[N, K, V](first, second)
}) })
} }
func UnionFirstSemigroup[N ~map[K]V, K comparable, V any]() S.Semigroup[N] { func UnionFirstSemigroup[N ~map[K]V, K comparable, V any]() S.Semigroup[N] {
return S.MakeSemigroup(func(first N, second N) N { return S.MakeSemigroup(func(first N, second N) N {
return unionLast(second, first) return unionLast[N, K, V](second, first)
}) })
} }

View File

@ -59,3 +59,8 @@ func First[A any]() Semigroup[A] {
func Last[A any]() Semigroup[A] { func Last[A any]() Semigroup[A] {
return MakeSemigroup(F.Second[A, A]) return MakeSemigroup(F.Second[A, A])
} }
// ToMagma converts a semigroup to a magma
func ToMagma[A any](s Semigroup[A]) M.Magma[A] {
return s
}