[Haskell-cafe] Unexpected result from Data.Compact.inCompact?
bertram.felgenhauer at googlemail.com
Wed Jun 26 16:08:26 UTC 2019
Viktor Dukhovni wrote:
> I am seeing surprising results from 'inCompact' after 'compact'.
> It seems there are additional limitations on what can be compacted,
> with 'compact' not throwing a 'CompactionFailed' exception in some
> cases, and yet not compacting the value. Is this expected?
This seems to be a documentation problem. `compact` forces and copies
/most/ of the data, but there are some exceptions:
- data that is already compacted is not copied
(this does not happen in your example, I think)
- statically allocated data is not copied either.
This includes nullary constructors like (), , or
Data.Map.Internal.Tip (the empty map) as well as many statically
known values like 42 :: Int
See also shouldCompact(),
which is called several times in stg_compactAddWorkerzh,
More information about the Haskell-Cafe