acowley / concurrent-machines Goto Github PK
View Code? Open in Web Editor NEWConcurrency features for the Haskell machines package
License: BSD 3-Clause "New" or "Revised" License
Concurrency features for the Haskell machines package
License: BSD 3-Clause "New" or "Revised" License
I've done some graphing of processes using buffer
and bufferConnect
and noticed some strange behaviour.
source [1..32] ~> bufferConnect 5 (worker (*2) 1 2) (worker id 2 4)
So bufferConnect
does what I'd expect which is run as much as it can until it's got 5 items buffered, and then only run when downstream takes an item.
source [1..32] ~> buffer 5 (worker (*2) 1 2) ~> worker id 2 4
But buffer
doesn't seem to do the same, it only buffers one item and waits until it empties completely before a new item is forced, which makes downstream wait. The same difference exists between rollingConnect
and rolling
too.
source [1..32] ~> rollingConnect 5 (worker (*2) 1 2) (worker id 2 4)
source [1..32] ~> rolling 5 (worker (*2) 1 2) ~> worker id 2 4
worker
takes a function a -> b
, an id number, and a delay for threadDelay
, so nothing special.
(Plots were done with splot).
If I have a construct
x <- await <|> yield something *> stop
This does not give deterministic result. Sometime it misses the last yield, skips the value. As a result last iteration is skipped.
The problem is usually with above construct.
Citing from http://hydra.cryp.to/build/1066421/log/raw:
Running 1 test suites...
Test suite tests: RUNNING...
concurrent-machines
pipeline: FAIL (0.49s)
Consistent results
Parallelism
Pipeline faster than sequential(0.176836,0.308616)
1 out of 1 tests failed (0.49s)
Test suite tests: FAIL
Hello,
I've been trying to accomplish a small program using Conduit, Pipes, Machines, and now Concurrent-Machines. I thought I'd finally found the solution with splitProd
, but I now find I really need something more like mergeProd
:
ProcessT m a r -> ProcessT m b r -> ProcessT m (a, b) r
I want to be able to split a source in two, perform different processes on each side (possibly in lock-step), and then merge the results, either automatically with a tuple, or manually with another Process argument.
It doesn't even really need concurrency support as far as I can tell, but the closest thing to what I've been looking for seems to be splitProd so I thought it couldn't hurt to ask if it falls under the scope of concurrent-machines here.
Feel free to close the issue if it's misplaced!
Easiest fix: change lower bound to base >= 4.8
GHC 7.8 fails with
Configuring component lib from concurrent-machines-0.2.3.2
Preprocessing library concurrent-machines-0.2.3.2...
[1 of 8] Compiling Data.Machine.Regulated ( src/Data/Machine/Regulated.hs, /tmp/matrix-worker/1482362213/dist-newstyle/build/x86_64-linux/ghc-7.8.4/concurrent-machines-0.2.3.2/build/Data/Machine/Regulated.o )
[2 of 8] Compiling Data.Machine.Concurrent.AsyncStep ( src/Data/Machine/Concurrent/AsyncStep.hs, /tmp/matrix-worker/1482362213/dist-newstyle/build/x86_64-linux/ghc-7.8.4/concurrent-machines-0.2.3.2/build/Data/Machine/Concurrent/AsyncStep.o )
[3 of 8] Compiling Data.Machine.Concurrent.Buffer ( src/Data/Machine/Concurrent/Buffer.hs, /tmp/matrix-worker/1482362213/dist-newstyle/build/x86_64-linux/ghc-7.8.4/concurrent-machines-0.2.3.2/build/Data/Machine/Concurrent/Buffer.o )
src/Data/Machine/Concurrent/Buffer.hs:34:51:
Could not deduce (Functor m) arising from a use of ‘<$>’
from the context (Monad m)
bound by the type signature for
drain :: Monad m =>
MachineStep m k a
-> (MachineStep m k a -> m (MachineStep m k' a))
-> m (MachineStep m k' a)
at src/Data/Machine/Concurrent/Buffer.hs:(28,10)-(31,31)
Possible fix:
add (Functor m) to the context of
the type signature for
drain :: Monad m =>
MachineStep m k a
-> (MachineStep m k a -> m (MachineStep m k' a))
-> m (MachineStep m k' a)
In the expression: Yield o . MachineT . go <$> runMachineT kd
In an equation for ‘go’:
go (Yield o kd) = Yield o . MachineT . go <$> runMachineT kd
In an equation for ‘drain’:
drain z k
= go z
where
go Stop = return Stop
go (Yield o kd) = Yield o . MachineT . go <$> runMachineT kd
go aStep = k aStep
whereas GHC 7.6 fails with
Configuring component lib from concurrent-machines-0.2.3.2
Preprocessing library concurrent-machines-0.2.3.2...
src/Data/Machine/Concurrent/Fanout.hs:18:8:
Could not find module `Data.Coerce'
Use -v to see a list of the files searched for.
This is a bit odd, and makes it somewhat difficult to combine with other stuff I enjoy (such as protolude-0.2 and the Stack nightlies). What's the reason for this choice?
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.