Looking for advice in trying to decide on a streaming solution #401
-
I recently asked a question on reddit's r/haskell (https://www.reddit.com/r/haskell/comments/18nkdt1/streaming_libraries_and_adhoc_pipelines_question/) and was recommended I'm the author of I've started orienting myself to writing an app that tries to fill the same niche as kmonad (keyboard remapping) but with a couple of serious improvements that all revolve around moving some of the decisions/implementations from inside the compiled haskell into the user config files. Basically, I want to define a number of basic event-stream computations that can be composed by users into event-stream transformations so as to define input-event remappings. I am happy to explain more, but I also don't want to ramble on, so I stop the general description here. Concretely, what I am trying to build is:
The streams need to be able to 'stretch' and 'compress', i.e: there are situations where multiple input stream elements are used to produce 1 output element, and conversely, sometimes single input-stream elements are used to produce multiple output elements. Additionally, the streams sometimes need to recurse. I found the Finally, I am concerned about performance. For most event-remappings the volume of events is actually quite low and I could get away with some inefficiency, but I've also tried to remap mouse-movement events, and that can actually be quite high-volume; not problematically so, but I also don't think people would want to dedicate a sizable percentage of their CPU to their input-remapper. Sorry if this is all a bit rambly and mixed-up. That's currently the state of my mind :-). I look forward to any feedback around my situation, the problem I am sketching, or other general advice. Please feel free to ask for clarification. Best, D |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi @david-janssen , glad you found your way here! I think the right choice has a lot to do with the relation and synchronicity between output and input, as you've already observed.
You can emulate such a resampling buffer with processBuffer :: MSF m (Maybe Event, [Event]) (Maybe Output, [Event])
processBuffer = arr $ \case ->
-- We have received a new event, but we can't process it right now
(Just event, events) -> (Nothing, event : events)
-- No event, but external trigger to produce output
(Nothing, events) -> (Just $ produceOutput events, [])
process :: MSF m (Maybe Event) (Maybe Output)
process = feedback processBuffer You would then have to drive this |
Beta Was this translation helpful? Give feedback.
-
As mentioned above, I ended up experimenting more with the various libraries, and ended up getting very satisfactory behavior from |
Beta Was this translation helpful? Give feedback.
As mentioned above, I ended up experimenting more with the various libraries, and ended up getting very satisfactory behavior from
pipes
. I will still keep my eye on this thread and am very happy to hear input and ideas, but I am not currently stuck anymore.