2

我正在阅读现实世界的haskell书。许多示例没有在最近的 GHC 上编译。我不确定在哪里可以找到 GHC 发生的更改,而 Google 在查找我看到的错误消息时也不是很及时。似乎在 MArrays 的实现中一定有一些变化?

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.4.1

和:

$ ghc -o bloom BloomFilter/Mutable.hs
[2 of 2] Compiling BloomFilter.Mutable ( BloomFilter/Mutable.hs, BloomFilter/Mutable.o )

BloomFilter/Mutable.hs:21:36:
    No instance for (Data.Array.Base.MArray
                       Data.Array.Base.UArray Bool (ST s))
      arising from a use of `newArray'
    Possible fix:
      add an instance declaration for
      (Data.Array.Base.MArray Data.Array.Base.UArray Bool (ST s))
    In the second argument of `liftM', namely
      `newArray (0, numBits - 1) False'
    In the expression: MB hash `liftM` newArray (0, numBits - 1) False
    In an equation for `new':
        new hash numBits = MB hash `liftM` newArray (0, numBits - 1) False

BloomFilter/Mutable.hs:26:36:
    No instance for (Data.Array.Base.MArray
                       Data.Array.Base.UArray Bool (ST s))
      arising from a use of `getBounds'
    Possible fix:
      add an instance declaration for
      (Data.Array.Base.MArray Data.Array.Base.UArray Bool (ST s))
    In the second argument of `liftM', namely
      `getBounds (mutArray filt)'
    In the expression: (succ . snd) `liftM` getBounds (mutArray filt)
    In an equation for `length':
        length filt = (succ . snd) `liftM` getBounds (mutArray filt)

BloomFilter/Mutable.hs:30:77:
    Couldn't match expected type `MutBloom s0 a0'
                with actual type `Word32'
    In the second argument of `writeArray', namely `bit'
    In the expression: writeArray (mutArray) bit True
    In the first argument of `mapM_', namely
      `(\ bit -> writeArray (mutArray) bit True)'

BloomFilter/Mutable.hs:40:44:
    No instance for (Data.Array.Base.MArray
                       Data.Array.Base.UArray Bool (ST s))
      arising from a use of `readArray'
    Possible fix:
      add an instance declaration for
      (Data.Array.Base.MArray Data.Array.Base.UArray Bool (ST s))
    In the first argument of `allM', namely
      `(readArray (mutArray filt))'
    In the second argument of `(>>=)', namely
      `allM (readArray (mutArray filt))'
    In the expression:
      indices filt elt >>= allM (readArray (mutArray filt))
4

0 回答 0