GHC.Num 模块中的 I# 和 +# 等运算符是什么意思?

What does the operators like I# and +# mean in GHC.Num module?

我打开了 GHC/Num.lhs 文件,可以找到如下代码:

instance  Num Int  where
    I# x + I# y = I# (x +# y)
    I# x - I# y = I# (x -# y)
    negate (I# x) = I# (negateInt# x)
    I# x * I# y = I# (x *# y)
    abs n  = if n `geInt` 0 then n else negate n

    signum n | n `ltInt` 0 = negate 1
             | n `eqInt` 0 = 0
             | otherwise   = 1

    {-# INLINE fromInteger #-}   -- Just to be sure!
    fromInteger i = I# (integerToInt i)

它们是 GHC 实施的某种内在运算符吗?

它们是 GHC primops,即未在 Haskell 中实现但由运行时提供的原始操作。

这些特殊的是 declared in GHC.Prim and implement unboxed IntsInt# 是未装箱的 Int 的类型,I#Int 的构造函数(即 data Int = I# Int#),而+#Int#加法。