no-unused-imports for only one import

Hello, I would like to set -Wno-unused-imports for only one import, is it possible and how to do it ? thanks for your advices. Frederic

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

On Fri, 9 Aug 2024, PICCA Frederic-Emmanuel wrote:
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.
Then just put the same HS_VERSION check around the import.

Unfortunately the status quo is indeed to use CPP around imports as well. One can imagine, with modifier syntax, some dedicated version of disabling warnings locally, but it is not something that has been implemented or even proposed yet. On 8/9/24 12:12, Henning Thielemann wrote:
On Fri, 9 Aug 2024, PICCA Frederic-Emmanuel wrote:
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.
Then just put the same HS_VERSION check around the import. _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

I haven't made a proposal yet, still waiting to hear back from someone about one possible tricky situation, but I actually do have a plan for this (`import Module (..)` as proposed syntax) and at some point I should put it up as an official proposal. On Fri, Aug 9, 2024 at 7:10 AM PICCA Frederic-Emmanuel < frederic-emmanuel.picca@synchrotron-soleil.fr> wrote:
thanks you all for your help
Fred _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
-- brandon s allbery kf8nh allbery.b@gmail.com

I don't believe so, because flags are set on a module basis and you need more granular control. Having been in your situation many times, what I often do is to define a cabal flag called "development" and in my ghc-options stanza I write: if flag(development) ghc-options: -Wno-unused-imports -Wno-unused-packages Then during CI I disable this flag. Cheers, Hécate Le 09/08/2024 à 10:49, PICCA Frederic-Emmanuel a écrit :
Hello,
I would like to set -Wno-unused-imports for only one import,
is it possible and how to do it ?
thanks for your advices.
Frederic _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
-- Hécate ✨ 🐦: @TechnoEmpress IRC: Hecate WWW:https://glitchbra.in RUN: BSD
participants (5)
-
Brandon Allbery
-
Georgi Lyubenov
-
Henning Thielemann
-
Hécate
-
PICCA Frederic-Emmanuel