[Haskell-cafe] no-unused-imports for only one import

PICCA Frederic-Emmanuel frederic-emmanuel.picca at synchrotron-soleil.fr
Fri Aug 9 09:06:24 UTC 2024


>   import Your.Module ()
> 
> trick? That is, add empty parenthesis after your import?


This code is a binding to a library and depending on values this import is necessary or not.

encodeDataspace :: Dataspace -> IO BS.ByteString
encodeDataspace (Dataspace space_id) =
    withOutByteString $ \buf bufSz ->
        withInOut_ bufSz $ \ioBufSz ->
            withErrorCheck_ $
#if H5_VERSION_GE(1,12,0)
# if H5Sencode_vers == 2
                h5s_encode space_id buf ioBufSz h5p_DEFAULT
# elif H5Sencode_vers == 1
                h5s_encode space_id buf ioBufSz
# else
#  error "H5Sencode_vers set to invalid value"
# endif
#else
                h5s_encode space_id buf ioBufSz
#endif


look at the h5p_DEFAULT which comes from the sus-named import.

If I put () I think that when 5Sencode_vers == 2, the compilation failed...

Fred


More information about the Haskell-Cafe mailing list