Instances1Show
Show ComparisonDefined in ghc-10.0.0.20260917 · GHC.Core.Opt.Range
:: a typeCtrl KGHC 10.0.0.20260917 · lts/ghc-10.0.x · 8174fa4 · 2026-10-11
Moduleghc-10.0.0.20260917GHC2024
Range analysis
See Note [Value range analysis]
Show ComparisonDefined in ghc-10.0.0.20260917 · GHC.Core.Opt.RangeA range (minBound,maxBound)
Bounds may not be known.
Return the Integer range of an expression
Compute the intersection of two overlapping ranges.
If the two ranges don't overlap, result is undefined.
Used for casts that share representation over a sub-range (e.g. [0,127] for Word8# ([0,255]) and Int8# ([-128,127]))
If from_range isn't fully included into to_range, then we return to_range. That's because for now we don't have a way to track disjoined ranges. E.g. if we wanted to cast -1,10 into 0,255, we would need to represent a range union: [0,10] U 255,255
We also use this function to ensure that the result of an arithmetic operation on ranges didn't overflow/underflow.
Compare two ranges
See Note [Value range analysis]