primetalk / goio Goto Github PK
View Code? Open in Web Editor NEWAn implementation of IO, Stream, Fiber for golang inspired by cats and fs2
License: MIT License
An implementation of IO, Stream, Fiber for golang inspired by cats and fs2
License: MIT License
It should combine two maps. In case when a key is present in both maps, it should combine
values.
Could be used for filters and exists.
when using stream.FanOut
we should react to a failure in a sibling stream.
A method could be more convenient. The old variant should be kept for compatibility.
Maps a slice inside IO.
Something like monad transformer.
Runs a second IO[Unit] in parallel. Automatically performs conversion to Either and back to A.
Golang allows to return two values simultaneously. We should leverage that in pairs.
This should be a curried function convenient to use with Filter.
func Contains[A comparable](as map[A]struct{}) func(a A) bool
We should be able to specify a timeout when joining fiber. In this case it'll error out with timeout exception.
This should create another map with transformed keys.
It should allow aggregation of values if the key happened to be the same.
Each IO element of the stream should be wrapped. So that if any of them fail, stream will produce a wrapped error.
func LiftFunc( func(A) B) func(A) IO[B]
Filter and FilterNot together
slice.
, stream.
This is a useful function.
Sometimes we have the partial state that requires some handling in case of errors.
Pipe[A,B] -> Pipe[B, C] = Pipe[A, C]
Maintain the current value in state. On finish it should return the last preserved value.
Currently we have ThroughExecutionContext which preserves the order of tasks. If one of the tasks takes much longer, it'll delay other tasks.
We might want to support unordered execution to achieve maximum throughput.
It might even return IO.
go-lang context.Context
might be used for compatibility purposes.
Hey nice library!
Would be good to understand the perks and what not of using this against an imperative approach.
Can you add benchmarks reports in the README file pls?
map.Keys
map.Merge
stream.Eval(io.Fail) -> ThroughExecutionContext -> hangs forever instead of failing fast.
Some resources require different action in case of failure. In particular, DB transactions and S3 multipart uploads.
t := transaction.New[T](acquire IO[T], rollback, commit func(T) IO) transaction.TransactionalResource[T]
transaction.Within[T, A](t, func (t) IO[A]) IO[A]
github.com/primetalk/goio/io.Eval[...].func1
github.com/primetalk/[email protected]/io/io.go:50
github.com/primetalk/goio/io.FlatMap[...].func1
github.com/primetalk/[email protected]/io/io.go:124
github.com/primetalk/goio/io.Fold[...].func1
github.com/primetalk/[email protected]/io/io.go:172
github.com/primetalk/goio/io.MapErr[...].func1
github.com/primetalk/[email protected]/io/io.go:91
github.com/primetalk/goio/io.FlatMap[...].func1.1
github.com/primetalk/[email protected]/io/io.go:129
github.com/primetalk/goio/io.MapErr[...].func1
github.com/primetalk/[email protected]/io/io.go:91
github.com/primetalk/goio/io.MapErr[...].func1
github.com/primetalk/[email protected]/io/io.go:110
github.com/primetalk/goio/io.FlatMap[...].func1
github.com/primetalk/[email protected]/io/io.go:124
github.com/primetalk/goio/io.Fold[...].func1
github.com/primetalk/[email protected]/io/io.go:172
github.com/primetalk/goio/io.MapErr[...].func1
github.com/primetalk/[email protected]/io/io.go:91
github.com/primetalk/goio/io.FlatMap[...].func1.1
github.com/primetalk/[email protected]/io/io.go:129
github.com/primetalk/goio/io.FlatMap[...].func1
github.com/primetalk/[email protected]/io/io.go:124
github.com/primetalk/goio/io.FlatMap[...].func1
github.com/primetalk/[email protected]/io/io.go:140
github.com/primetalk/goio/io.FlatMap[...].func1
github.com/primetalk/[email protected]/io/io.go:124
github.com/primetalk/goio/io.FlatMap[...].func1
github.com/primetalk/[email protected]/io/io.go:124
github.com/primetalk/goio/io.FlatMap[...].func1
github.com/primetalk/[email protected]/io/io.go:124
github.com/primetalk/goio/io.FlatMap[...].func1
github.com/primetalk/[email protected]/io/io.go:124
github.com/primetalk/goio/io.FlatMap[...].func1
github.com/primetalk/[email protected]/io/io.go:124
github.com/primetalk/goio/io.Fold[...].func1
github.com/primetalk/[email protected]/io/io.go:172
github.com/primetalk/goio/io.FlatMap[...].func1.1
github.com/primetalk/[email protected]/io/io.go:129
github.com/primetalk/goio/io.Fold[...].func1
github.com/primetalk/[email protected]/io/io.go:172
github.com/primetalk/goio/io.Fold[...].func1
github.com/primetalk/[email protected]/io/io.go:186
github.com/primetalk/goio/io.FlatMap[...].func1.1
github.com/primetalk/[email protected]/io/io.go:129
github.com/primetalk/goio/io.FlatMap[...].func1
github.com/primetalk/[email protected]/io/io.go:124
github.com/primetalk/goio/io.FlatMap[...].func1
github.com/primetalk/[email protected]/io/io.go:140
github.com/primetalk/goio/io.Fold[...].func1
github.com/primetalk/[email protected]/io/io.go:172
github.com/primetalk/goio/io.FlatMap[...].func1
github.com/primetalk/[email protected]/io/io.go:124
github.com/primetalk/goio/io.Fold[...].func1
github.com/primetalk/[email protected]/io/io.go:172
github.com/primetalk/goio/io.FlatMap[...].func1.1
github.com/primetalk/[email protected]/io/io.go:129
github.com/primetalk/goio/io.Fold[...].func1
github.com/primetalk/[email protected]/io/io.go:172
github.com/primetalk/goio/io.Fold[...].func1
github.com/primetalk/[email protected]/io/io.go:186
Reading line-based files sometimes require the availability of header line in subsequent calls. It's possible using StateFlatMap, but probably there could be a simpler solution.
Signature might look like
func Retry[A any, S any](ioa IO[A], strategy func(s S, err error) option.Option[S], s S) IO[A]
s
- state of the strategy. Strategy might use it to count the number of retries, or time between invocations. If strategy decides not to retry, it should return option.None
.
It might have the following signature:
func Partition[A any](
predicate func(A)bool,
trueHandler func(Stream[A]) io.IO[Unit],
falseHandler func(Stream[A]) io.IO[Unit],
) io.IO[Unit]
Currently streams can only use resources provided at the top level via ordinary resource.Use
.
Sometimes we need to pass streams around and we wish that resources are correctly released when stream is either finished or thrown away.
or GroupByEval
These functions could be helpful when a function is needed.
If there is a unique key for slice elements, that key could be used to build a fast index based on map.
func BuildUniqueIndex[A any, K comparable](as []A, func (A) K) (map[K]A, err)
It may fail if the key value is not really unique.
Sometime this could be useful.
When we run a few calculations in an ExecutionContext, we may lose information about what request failed. So instead of a simple GoResult
we should keep some information about the source object.
This could be tricky, as we send IOs.
If we want to run some evaluation on every element, but then proceed stream processing with the very same element. For instance, log some statistics.
This should perform some operation on the error and fail with the same error.
(stream.?)
Like fold left but starts with the first element.
Existing ThroughPool
is using an incompatible "pool". We'd better replace it with ExecutionContext.
It is printed without request.
This transducer should buffer incoming data and produce chunks of sizes within provided range.
Only if there is not enough data, the single part could be smaller than the required min amount.
A function to remove elements of the second slice from the first one.
Something like this:
type Consumer[A any] = func (A) io.IOUnit
A pure sideeffect.
When we want to know the duration of execution of a certain IO.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.