Skip to content

Commit f1eca00

Browse files
authored
make Apply public in F[A, B] (#70)
1 parent 9eae035 commit f1eca00

File tree

5 files changed

+26
-34
lines changed

5 files changed

+26
-34
lines changed

pipe/fork/fork.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func Filter[A any](ctx context.Context, par int, in <-chan A, f F[A, bool]) <-ch
3535

3636
var a A
3737
for a = range in {
38-
if take, err := f.apply(a); take && err == nil {
38+
if take, err := f.Apply(a); take && err == nil {
3939
select {
4040
case out <- a:
4141
case <-ctx.Done():
@@ -68,7 +68,7 @@ func ForEach[A any](ctx context.Context, par int, in <-chan A, f F[A, A]) <-chan
6868

6969
var a A
7070
for a = range in {
71-
f.apply(a)
71+
f.Apply(a)
7272
select {
7373
case <-ctx.Done():
7474
return
@@ -102,7 +102,7 @@ func FMap[A, B any](ctx context.Context, par int, in <-chan A, fmap FF[A, B]) (<
102102

103103
var a A
104104
for a = range in {
105-
if err := fmap.apply(ctx, a, out); err != nil {
105+
if err := fmap.Apply(ctx, a, out); err != nil {
106106
if !fmap.catch(ctx, err, exx) {
107107
return
108108
}
@@ -193,7 +193,7 @@ func Map[A, B any](ctx context.Context, par int, in <-chan A, f F[A, B]) (<-chan
193193
)
194194

195195
for a = range in {
196-
val, err = f.apply(a)
196+
val, err = f.Apply(a)
197197
if err != nil {
198198
if !f.catch(ctx, err, exx) {
199199
return
@@ -242,7 +242,7 @@ func Partition[A any](ctx context.Context, par int, in <-chan A, f F[A, bool]) (
242242
var a A
243243
for a = range in {
244244
select {
245-
case sel(f.apply(a)) <- a:
245+
case sel(f.Apply(a)) <- a:
246246
case <-ctx.Done():
247247
return
248248
}

pipe/fork/function.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type Arrow[A, B any] = func(context.Context, A, chan<- B) error
2525

2626
// Go channel morphism 𝑓: A ⟼ B
2727
type F[A, B any] interface {
28-
apply(A) (B, error)
28+
Apply(A) (B, error)
2929
errch(cap int) chan error
3030
catch(context.Context, error, chan<- error) bool
3131
pipef() pipe.F[A, B]
@@ -45,8 +45,7 @@ func Lift[A, B any](f EitherE[A, B]) F[A, B] {
4545

4646
type pure[A, B any] EitherE[A, B]
4747

48-
//lint:ignore U1000 false positive
49-
func (f pure[A, B]) apply(a A) (B, error) {
48+
func (f pure[A, B]) Apply(a A) (B, error) {
5049
return EitherE[A, B](f)(a)
5150
}
5251

@@ -74,8 +73,7 @@ func Try[A, B any](f EitherE[A, B]) F[A, B] {
7473

7574
type try[A, B any] EitherE[A, B]
7675

77-
//lint:ignore U1000 false positive
78-
func (f try[A, B]) apply(a A) (B, error) {
76+
func (f try[A, B]) Apply(a A) (B, error) {
7977
return EitherE[A, B](f)(a)
8078
}
8179

@@ -103,7 +101,7 @@ func (f try[A, B]) pipef() pipe.F[A, B] {
103101

104102
// Go channel functor 𝓕: A ⟼ B
105103
type FF[A, B any] interface {
106-
apply(context.Context, A, chan<- B) error
104+
Apply(context.Context, A, chan<- B) error
107105
errch(cap int) chan error
108106
catch(context.Context, error, chan<- error) bool
109107
}
@@ -116,8 +114,7 @@ func LiftF[A, B any](f Arrow[A, B]) FF[A, B] {
116114

117115
type puref[A, B any] Arrow[A, B]
118116

119-
//lint:ignore U1000 false positive
120-
func (f puref[A, B]) apply(ctx context.Context, a A, b chan<- B) error {
117+
func (f puref[A, B]) Apply(ctx context.Context, a A, b chan<- B) error {
121118
return Arrow[A, B](f)(ctx, a, b)
122119
}
123120

@@ -140,8 +137,7 @@ func TryF[A, B any](f Arrow[A, B]) FF[A, B] {
140137

141138
type tryf[A, B any] Arrow[A, B]
142139

143-
//lint:ignore U1000 false positive
144-
func (f tryf[A, B]) apply(ctx context.Context, a A, b chan<- B) error {
140+
func (f tryf[A, B]) Apply(ctx context.Context, a A, b chan<- B) error {
145141
return Arrow[A, B](f)(ctx, a, b)
146142
}
147143

pipe/function.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type Arrow[A, B any] = func(context.Context, A, chan<- B) error
2121

2222
// Go channel morphism 𝑓: A ⟼ B
2323
type F[A, B any] interface {
24-
apply(A) (B, error)
24+
Apply(A) (B, error)
2525
errch(cap int) chan error
2626
catch(context.Context, error, chan<- error) bool
2727
}
@@ -40,8 +40,7 @@ func Lift[A, B any](f EitherE[A, B]) F[A, B] {
4040

4141
type pure[A, B any] EitherE[A, B]
4242

43-
//lint:ignore U1000 false positive
44-
func (f pure[A, B]) apply(a A) (B, error) {
43+
func (f pure[A, B]) Apply(a A) (B, error) {
4544
return EitherE[A, B](f)(a)
4645
}
4746

@@ -64,8 +63,7 @@ func Try[A, B any](f EitherE[A, B]) F[A, B] {
6463

6564
type try[A, B any] EitherE[A, B]
6665

67-
//lint:ignore U1000 false positive
68-
func (f try[A, B]) apply(a A) (B, error) {
66+
func (f try[A, B]) Apply(a A) (B, error) {
6967
return EitherE[A, B](f)(a)
7068
}
7169

@@ -88,7 +86,7 @@ func (f try[A, B]) catch(ctx context.Context, err error, exx chan<- error) bool
8886

8987
// Go channel functor 𝓕: A ⟼ B
9088
type FF[A, B any] interface {
91-
apply(context.Context, A, chan<- B) error
89+
Apply(context.Context, A, chan<- B) error
9290
errch(cap int) chan error
9391
catch(context.Context, error, chan<- error) bool
9492
}
@@ -101,8 +99,7 @@ func LiftF[A, B any](f Arrow[A, B]) FF[A, B] {
10199

102100
type puref[A, B any] Arrow[A, B]
103101

104-
//lint:ignore U1000 false positive
105-
func (f puref[A, B]) apply(ctx context.Context, a A, b chan<- B) error {
102+
func (f puref[A, B]) Apply(ctx context.Context, a A, b chan<- B) error {
106103
return Arrow[A, B](f)(ctx, a, b)
107104
}
108105

@@ -125,8 +122,7 @@ func TryF[A, B any](f Arrow[A, B]) FF[A, B] {
125122

126123
type tryf[A, B any] Arrow[A, B]
127124

128-
//lint:ignore U1000 false positive
129-
func (f tryf[A, B]) apply(ctx context.Context, a A, b chan<- B) error {
125+
func (f tryf[A, B]) Apply(ctx context.Context, a A, b chan<- B) error {
130126
return Arrow[A, B](f)(ctx, a, b)
131127
}
132128

pipe/pipe.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func Emit[T any](ctx context.Context, cap int, frequency time.Duration, f F[int,
3636
for i := 0; true; i++ {
3737
time.Sleep(frequency)
3838

39-
val, err = f.apply(i)
39+
val, err = f.Apply(i)
4040
if err != nil {
4141
if !f.catch(ctx, err, exx) {
4242
return
@@ -65,7 +65,7 @@ func Filter[A any](ctx context.Context, in <-chan A, f F[A, bool]) <-chan A {
6565

6666
var a A
6767
for a = range in {
68-
if take, err := f.apply(a); take && err == nil {
68+
if take, err := f.Apply(a); take && err == nil {
6969
select {
7070
case out <- a:
7171
case <-ctx.Done():
@@ -87,7 +87,7 @@ func ForEach[A any](ctx context.Context, in <-chan A, f F[A, A]) <-chan struct{}
8787

8888
var x A
8989
for x = range in {
90-
f.apply(x)
90+
f.Apply(x)
9191
select {
9292
case <-ctx.Done():
9393
return
@@ -111,7 +111,7 @@ func FMap[A, B any](ctx context.Context, in <-chan A, fmap FF[A, B]) (<-chan B,
111111

112112
var a A
113113
for a = range in {
114-
if err := fmap.apply(ctx, a, out); err != nil {
114+
if err := fmap.Apply(ctx, a, out); err != nil {
115115
if !fmap.catch(ctx, err, exx) {
116116
return
117117
}
@@ -172,7 +172,7 @@ func Map[A, B any](ctx context.Context, in <-chan A, f F[A, B]) (<-chan B, <-cha
172172
)
173173

174174
for a = range in {
175-
val, err = f.apply(a)
175+
val, err = f.Apply(a)
176176
if err != nil {
177177
if !f.catch(ctx, err, exx) {
178178
return
@@ -210,7 +210,7 @@ func Partition[A any](ctx context.Context, in <-chan A, f F[A, bool]) (<-chan A,
210210
var a A
211211
for a = range in {
212212
select {
213-
case sel(f.apply(a)) <- a:
213+
case sel(f.Apply(a)) <- a:
214214
case <-ctx.Done():
215215
return
216216
}
@@ -238,7 +238,7 @@ func Unfold[A any](ctx context.Context, cap int, seed A, f F[A, A]) (<-chan A, <
238238
return
239239
}
240240

241-
seed, err = f.apply(seed)
241+
seed, err = f.Apply(seed)
242242
if err != nil {
243243
if !f.catch(ctx, err, exx) {
244244
return
@@ -318,7 +318,7 @@ func TakeWhile[A any](ctx context.Context, in <-chan A, f F[A, bool]) <-chan A {
318318

319319
var a A
320320
for a = range in {
321-
if take, err := f.apply(a); !take || err != nil {
321+
if take, err := f.Apply(a); !take || err != nil {
322322
return
323323
}
324324

pipe/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88

99
package pipe
1010

11-
const Version = "pipe/v2.0.0"
11+
const Version = "pipe/v2.0.1"

0 commit comments

Comments
 (0)