gpt4 book ai didi

haskell - 如何使用注释自定义 HLint 并将我的 Haskell 包标记为安全?

转载 作者:行者123 更新时间:2023-12-04 15:50:23 28 4
gpt4 key购买 nike

my package我有 several annotations帮助定制我对 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) #-}

但是当我尝试将我的包裹标记为安全时
{-# LANGUAGE Safe #-}

我明白了
    • 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) #-}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

在删除注释后,我可以安全地构建和测试而不会出错。

是否有另一种方法可以自定义 Hlint,让我的包裹被标记为安全?

最佳答案

而不是使用 ANN编译指示,你可以使用:

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

或者:
{- HLINT ignore "Use mappend" -}

前者将触发 GHC 关于未知编译指示的警告。

也可以看看:

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

关于haskell - 如何使用注释自定义 HLint 并将我的 Haskell 包标记为安全?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52955380/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com