Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use annotations to customize HLint and mark my Haskell package as Safe?

Tags:

haskell

In my package I have several annotations to help customize my use of hlint:

{-# ANN module ("HLint: ignore Use infix"::String) #-}
{-# ANN module ("HLint: ignore Use mappend"::String) #-}
{-# ANN module ("HLint: ignore Use fmap"::String) #-}
{-# ANN module ("HLint: error Redundant $"::String) #-}
{-# ANN module ("HLint: ignore Use ."::String) #-}

But when I try to mark my package as Safe with

{-# LANGUAGE Safe #-}

I get

    • Annotations are not compatible with Safe Haskell.
      See https://ghc.haskell.org/trac/ghc/ticket/10826
    • In the annotation:
        {-# ANN module ("HLint: ignore Use ." :: String) #-}
   |
80 | {-# ANN module ("HLint: ignore Use ."::String) #-}
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

while with the annotations removed, I can build and test as Safe without errors.

Is there an alternative way to customize Hlint that allows my package to be marked as Safe?

like image 571
orome Avatar asked Oct 23 '18 18:10

orome


1 Answers

Instead of using ANN pragmas, you can use either:

{-# HLINT ignore "Use mappend" #-}

or:

{- HLINT ignore "Use mappend" -}

The former will trigger a warning from GHC about an unknown pragma.

See also:

https://github.com/ndmitchell/hlint#ignoring-hints

like image 97
zenhack Avatar answered Sep 19 '22 14:09

zenhack