[Haskell-cafe] how to simplify ressources access and pipes steam

PICCA Frederic-Emmanuel frederic-emmanuel.picca at synchrotron-soleil.fr
Thu May 21 07:03:36 UTC 2020


> Do you mean it's ugly because of the nested withHdf4PathP? If so, have you considered ResourceT?

This is more about the complex signature of the function.

> But I saw something else that seems more noteworthy. Why is withUhvPathP being used to repeatedly open and close the same files using the filenames contained in dif? (I suppose withHdf5PathP opens and closes HDF5 files.) Why don't you open the > files once in the beginning of your loop and close them at the end? You can do this by wrapping everything in a ResourceT and use allocate.

withHdf5Path already us the MonadSafe from pipes, so the resources are opened only once during the process. (once per thread, because I process chunk of the data, one per thread).


More information about the Haskell-Cafe mailing list