Skip to content

`Note [NOINLINE someNatVal]` possibly outdated?

Summary

In GHC.TypeNats the NOINLINE someNatVal note talks about care around use of Any in the definition of someNatVal, with additional related text in GHC.HsToCore.Expr.

But actual use of Any in combination with withDict is nowhere to be found in either the compiler or the base library. Only the testsuite appears to contain such usage:

testsuite/tests/ghci/scripts/T19667Ghci.hs--- See Note [NOINLINE someNatVal] in GHC.TypeNats
testsuite/tests/ghci/scripts/T19667Ghci.hs-{-# NOINLINE reifySymbol #-}
testsuite/tests/ghci/scripts/T19667Ghci.hs-reifySymbol :: forall r. String -> (forall (n :: Symbol). KnownSymbol n => Proxy n -> r) -> r
testsuite/tests/ghci/scripts/T19667Ghci.hs:reifySymbol n k = withDict @(SSymbol Any) @(KnownSymbol Any) (SSymbol n) (k @Any) (Proxy @(Any @Symbol))
--
testsuite/tests/typecheck/should_fail/T16646Fail.hs-reify :: forall a r. a -> (forall (s :: Type). Reifies s a => Proxy s -> r) -> r
testsuite/tests/typecheck/should_fail/T16646Fail.hs:reify a k = withDict @_ @(Reifies (Any @Type) a) (const a) (k @Any) Proxy
--
testsuite/tests/typecheck/should_run/T16646.hs-reify :: forall a r. a -> (forall (s :: Type). Reifies s a => Proxy s -> r) -> r
testsuite/tests/typecheck/should_run/T16646.hs-{-# NOINLINE reify #-} -- See Note [NOINLINE someNatVal] in GHC.TypeNats
testsuite/tests/typecheck/should_run/T16646.hs:reify a k = withDict @(forall (proxy :: Type -> Type). proxy Any -> a)
testsuite/tests/typecheck/should_run/T16646.hs-                     @(Reifies (Any @Type) a)
testsuite/tests/typecheck/should_run/T16646.hs-                     (const a) (k @Any) Proxy
--
testsuite/tests/typecheck/should_run/T19667.hs--- See Note [NOINLINE someNatVal] in GHC.TypeNats
testsuite/tests/typecheck/should_run/T19667.hs-{-# NOINLINE reifySymbol #-}
testsuite/tests/typecheck/should_run/T19667.hs-reifySymbol :: forall r. String -> (forall (n :: Symbol). KnownSymbol n => Proxy n -> r) -> r
testsuite/tests/typecheck/should_run/T19667.hs:reifySymbol n k = withDict @(SSymbol Any) @(KnownSymbol Any) (SSymbol n) (k @Any) (Proxy @(Any @Symbol))

Even the reflection package does not appear to be explicitly using Any anywhere obvious. I find this somewhat confusing...

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information