mirror of
https://github.com/IBM/fp-go.git
synced 2026-03-20 13:58:04 +02:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
99a0ddd4b6 |
15
v2/internal/filterable/types.go
Normal file
15
v2/internal/filterable/types.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package filterable
|
||||
|
||||
import (
|
||||
"github.com/IBM/fp-go/v2/option"
|
||||
"github.com/IBM/fp-go/v2/pair"
|
||||
)
|
||||
|
||||
type (
|
||||
Option[A any] = option.Option[A]
|
||||
Separated[A, B any] = pair.Pair[A, B]
|
||||
|
||||
FilterType[A, HKTA any] = func(func(A) bool) func(HKTA) HKTA
|
||||
|
||||
FilterMapType[A, B, HKTA, HKTB any] = func(func(A) Option[B]) func(HKTA) HKTB
|
||||
)
|
||||
27
v2/internal/witherable/filter.go
Normal file
27
v2/internal/witherable/filter.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package witherable
|
||||
|
||||
import (
|
||||
"github.com/IBM/fp-go/v2/function"
|
||||
"github.com/IBM/fp-go/v2/internal/filterable"
|
||||
"github.com/IBM/fp-go/v2/internal/functor"
|
||||
)
|
||||
|
||||
func Filter[A, HKT_G_A, HKT_F_HKT_G_A any](
|
||||
fmap functor.MapType[HKT_G_A, HKT_G_A, HKT_F_HKT_G_A, HKT_F_HKT_G_A],
|
||||
ffilter filterable.FilterType[A, HKT_G_A],
|
||||
) func(func(A) bool) func(HKT_F_HKT_G_A) HKT_F_HKT_G_A {
|
||||
return function.Flow2(
|
||||
ffilter,
|
||||
fmap,
|
||||
)
|
||||
}
|
||||
|
||||
func FilterMap[A, B, HKT_G_A, HKT_G_B, HKT_F_HKT_G_A, HKT_F_HKT_G_B any](
|
||||
fmap functor.MapType[HKT_G_A, HKT_G_B, HKT_F_HKT_G_A, HKT_F_HKT_G_B],
|
||||
ffilter filterable.FilterMapType[A, B, HKT_G_A, HKT_G_B],
|
||||
) func(func(A) Option[B]) func(HKT_F_HKT_G_A) HKT_F_HKT_G_B {
|
||||
return function.Flow2(
|
||||
ffilter,
|
||||
fmap,
|
||||
)
|
||||
}
|
||||
1
v2/internal/witherable/partition.go
Normal file
1
v2/internal/witherable/partition.go
Normal file
@@ -0,0 +1 @@
|
||||
package witherable
|
||||
7
v2/internal/witherable/type.go
Normal file
7
v2/internal/witherable/type.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package witherable
|
||||
|
||||
import "github.com/IBM/fp-go/v2/option"
|
||||
|
||||
type (
|
||||
Option[A any] = option.Option[A]
|
||||
)
|
||||
Reference in New Issue
Block a user