
26 Mar
2016
26 Mar
'16
2:59 p.m.
Hello, I try to write a sort of withxxx method whcih release a file withH5File :: FilePath -> (HId_t -> IO r) -> IO r withH5File name = bracket (withCString name acquire) h5f_close where acquire file = h5f_open file h5f_ACC_RDONLY h5p_DEFAULT In my case h5f_open return a HId_t value (HId_t Int) If something went wrong the returned value is negativ. In that case I do not need to h5f_close the file but instead return an error My question is how should I write the bracket part when the finaliser (h5f_close) depends on the result of the acquire part. thanks for your help Frederic