NegativeLiterals breaks an otherwise well-typed program
Summary
The following program fails to compile:
{-# LANGUAGE NegativeLiterals #-}
module Test where
tooLarge :: Int -> a
tooLarge _ = errorWithoutStackTrace ("!!: index too large")
{-# INLINABLE (!!) #-}
xs !! n = foldr (\x r k -> r (k-1)) tooLarge xs n
with the error
/home/sandy/Test.hs:9:18: error:
• Couldn't match type ‘Integer -> Int’ with ‘Int’
Expected type: Int -> t1
Actual type: (Integer -> Int) -> t1
• In the first argument of ‘foldr’, namely ‘(\ x r k -> r (k -1))’
However, this program will compile successfully under -XNoNegativeLiterals
. This might not be a minimal example, I didn't attempt to shrink it any further.
Steps to reproduce
Attempt to compile the above program.
Expected behavior
According to the documentation of -XNegativeLiterals
, this shouldn't affect the types of the program.
Environment
- GHC version used: 8.8 and 8.6
Optional:
- Operating System:
- System Architecture: