Skip to content

inCompact and isCompact don't seem to work

inCompact and isCompact always seem to return False

inCompact is supposed to indicate whether a certain value is in a particular region. isCompact is supposed to indicate whether a certain value is in any compact region. I have not been able to convince either of these to return True under any circumstances.

Steps to reproduce

import Data.Compact
import Control.Exception (evaluate)
import Control.DeepSeq
import System.Mem

main = do
  p <- evaluate $ force [1..10000 :: Integer]
  foo <- compact p
  performMajorGC -- Even this doesn't do the trick.
  isCompact p >>= print
  inCompact foo p >>= print
  print . sum $ getCompact foo

This prints False twice before successfully summing and printing the contents of foo. Optimization level makes no difference.

Expected behavior

I expect this to print True twice. Even if isCompact is too hard to implement, I would at least expect inCompact to work.

Environment

  • GHC version used: 8.10.1

Optional:

  • Operating System:
  • System Architecture:
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information