2

我正在尝试对紧密内部循环中使用的方法进行专门化,但 GHC 抱怨以下内容:

src/Mac/CoreGraphics/Image.hs:140:1: Warning:
    You cannot SPECIALISE `toRealFrac'
      because its definition has no INLINE/INLINABLE pragma
      (or its defining module `Data.Image.Pixel' was compiled without -O)

src/Mac/CoreGraphics/Image.hs:140:1: Warning:
    Ignoring useless SPECIALISE pragma for class method selector `toRealFrac'

但是,它显然是使用 -O 构建的:

/usr/local/bin/ghc --make -no-link -fbuilding-cabal-package -O -static -outputdir dist/build/imagesorter-hs/imagesorter-hs-tmp -odir dist/build/imagesorter-hs/imagesorter-hs-tmp -hidir dist/build/imagesorter-hs/imagesorter-hs-tmp -stubdir dist/build/imagesorter-hs/imagesorter-hs-tmp -i -idist/build/imagesorter-hs/imagesorter-hs-tmp -isrc -idist/build/autogen -Idist/build/autogen -Idist/build/imagesorter-hs/imagesorter-hs-tmp -optP-include -optPdist/build/autogen/cabal_macros.h -hide-all-packages -package-db dist/package.conf.inplace -package-id base-4.6.0.1-6c351d70a24d3e96f315cba68f3acf57 -XHaskell2010 src/ImageSorter.hs

很明显,我确实有 INLINABLE 编译指示:

instance PixelComponent Word8 where
  minValue = minBound
  maxValue = maxBound
  toRealFrac c = fromIntegral c / fromIntegral (maxValue :: Word8)
  {-# INLINABLE toRealFrac #-}

那么我做错了什么?

4

0 回答 0