pipe

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

package pipe provides functions useful to build a network of concurrent pipe processes the components of which are connected by channels.

Just - all these beautiful and useful generic definitions cannot be seen via godoc here, as they need to be private - initially.

This is due to the 'funny' way "genny" handles identifier-casing:

If the original generic type has a public (uppercase) name,
then generated identifiers will remain uppercase (and thus public)
and you may never generate private non-public (lowercased) identifiers.

Thus we need to start with a private id (such as `anyThing` here) and with private function names in order to respect Your freedom of choice.

I am awfully sorry for this inconvenience and provide two alternatives:

In the root of the repo is a complete generated version of `package pipe`
with a public generic type (`Any`). Thus, everything public is visible
(just: it's not intended for further use - it's way too large, isn't it?).

Under the `examples` folder there are directories with samples generated
for public types - and thus provide meaningful `godoc` documentation
for what is used in the particular context at hand.

Please enjoy to study and use what You find here.

And please feel free and encouraged to suggest, improve, comment or ask, You'll be welcome!

Think deep - code happy - be simple - see clear :-)

Example (Daisy)
t := intChan(1, 2, 3, 4, 5)
t2 := intTubeFunc(TimesN(2))
<-intDoneFunc(t2(t2(t)), p)
Output:

4
8
12
16
20
Example (One)
t := intChan(1, 2, 3, 4, 5)
t = intPipeFunc(t, TimesN(4))
<-intDoneFunc(t, p)
Output:

4
8
12
16
20
Example (Same1)
c1 := intChan(1, 2, 3, 4, 5)
c2 := intChan(1, 2, 3, 4, 5)

same := func(a, b int) bool { return a == b }
fmt.Println(<-intSame(same, c1, c2))
Output:

true
Example (Same2)
c1 := intChan(1, 2, 3, 4, 5)
c2 := intChan(1, 2, 3, 4, 5, 6)

same := func(a, b int) bool { return a == b }
fmt.Println(<-intSame(same, c1, c2))
Output:

false
Example (Three)
t := intChan(1, 2, 3, 4, 5)
t2 := intTubeFunc(TimesN(2))
<-intDoneFunc(t2(t2(t)), p)
Output:

4
8
12
16
20
Example (Two)
t := intChan(1, 2, 3, 4, 5)
t4 := intTubeFunc(TimesN(4))
<-intDoneFunc(t4(t), p)
Output:

4
8
12
16
20

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL