我正在尝试对紧密内循环中使用的方法进行专门化,但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 pragma:
instance PixelComponent Word8 where
minValue = minBound
maxValue = maxBound
toRealFrac c = fromIntegral c / fromIntegral (maxValue :: Word8)
{-# INLINABLE toRealFrac #-}
那么我做错了什么?