Since in GHCi the monomoprhism restriction is disabled, the last x
is a polymorphic value of type x :: Num a => a
. So it is not a simple integer, but a kind-of function DictNum a -> a
which is ready to create a value in any numeric type.
Indeed, x :: Int, x :: Float, x :: Double
will run and produce different values. These values are numerically the same, but computationally different, since they are representations in different types.
Since x
is, essentially, "multiple values, generated on demand", there is no single WHNF or NF here.
Note that if we compute (x :: Int) + (x :: Int)
, then x
is being recomputed twice: GHC in general will not "cache" the WHNF at type Int
for successive computations. This is similar to f 3 + f 3
, where f 3
is not cached (memoized).
This duplicate computation is precisely what the monomorphism restriction tries to avoid.