[Haskell-cafe] how to write a pipes Consumer which return a final state
PICCA Frederic-Emmanuel
frederic-emmanuel.picca at synchrotron-soleil.fr
Wed Feb 1 10:09:32 UTC 2023
Hello, I try to create a pipes which return at the end a Cube.
the process is quite simple
1) extract data from a file
2) comput a cube of data from these data
3) accumulate these cube during the process
4) when there is no more cube return the final cube
I am trying for now to write the part with the 'state' which is hiden in a recursion like this.
accumulateP :: (MonadIO m, Shape sh)
=> Cube sh -> Consumer (DataFrameSpace sh) m (Cube sh)
accumulateP cube = do
s <- await
accumulateP =<< (liftIO $ addSpace s cube)
the add Space method return the modified Cube
At some point I should see that await can not return a value and
I would decide to return the value instead of doing another loop
My question is how do I stop this recursion and return the final cube ?
thanks for your help.
More information about the Haskell-Cafe
mailing list