
On Mon, 14 Mar 2022, PICCA Frederic-Emmanuel wrote:
So I try with something simple
-- File
newtype H5FilePath = H5FilePath FilePath
instance DataResource H5FilePath where data OpenedDataResource H5FilePath = File acquireDataResource (H5FilePath f) = openFile (pack f) [ReadOnly] Nothing releaseDataResource = closeFile
but I end up with this sort of error
It means that openFile returns File type but your instance requires that it returns OpenedDataResource H5FilePath. That is, you must wrap the result of openFile in the File data constructor. I.e.: acquireDataResource (H5FilePath f) = File <$> openFile (pack f) [ReadOnly] Nothing releaseDataResource (File f) = closeFile f Since you used "data" instead of "type" in your type class, your data types are custom types per instance.