Skip to content

Instantly share code, notes, and snippets.

@Akii
Created November 29, 2018 18:21
Show Gist options
  • Save Akii/3f792f149b23a23dca0ecab9230e0569 to your computer and use it in GitHub Desktop.
Save Akii/3f792f149b23a23dca0ecab9230e0569 to your computer and use it in GitHub Desktop.
-- This is part of a pipeline that continously produces `ev`s
-- Essentially this is a fold or scan. I call `a` a "projection" of a series of `ev`s
projectionConsumer :: IORef a -> (ev -> a -> a) -> Consumer ev IO ()
projectionConsumer ref f = for cat $ modifyIORef' ref . f
-- projectionBConsumer :: IORef b -> (ev -> b -> b) ...
-- I now have this issue of composing multiple of these folds
-- What I resorted to is something like this
someOtherProjection :: IORef a -> IORef x -> IO ()
someOtherProjection refA refX = forever $ do
someA <- readIORef refA
writeIORef refX (transformAToX someA)
wait10Seconds
-- Somehow I'm looking for a way to compose all of this. `a`s above are an intermediate step of folding so to say.
-- But I also have to compose multiple projections.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment