Closed cjay closed 3 years ago
proxy# : forall k (a :: k). Proxy# a
has two type variables: the displayed type a :: k
and it's kind k
. Not sure why we don't need it anymore. Perhaps, due to some changes to the variable visibility & type applications extension in the new version of ghc.
Ugh, it seems there are a lot of warnings and errors in all 8.x versions of ghc now due to the changes in the type inference https://travis-ci.org/github/achirkin/easytensor/builds/763366711
I'll have a closer look on the weekend. Thanks for bringing this up!
This is very weird. It seems I was looking at proxy# from GHC.Prim
(I now see this module has a disclaimer not to use it directly), where it has no explicit forall
. However, GHC.Exts
seems to just reexport the proxy#
and Proxy#
from there. Now I wonder where Haddock gets the explicit forall
from. Even ghci
seems to agree with Haddock:
Prelude GHC.Exts> :t +v proxy#
proxy# :: forall k (a :: k). Proxy# a
The +v
should add {}
around inferred type variables that are not available for visible type application, if I understand the documentation correctly.
However:
Prelude GHC.Exts Data.Kind> :t proxy# @Int
proxy# @Int :: Proxy# Int
Prelude GHC.Exts Data.Kind> :t proxy# @Type @Int
<interactive>:1:1: error:
• Cannot apply expression of type ‘Proxy# Type’
to a visible type argument ‘Int’
• In the expression: proxy# @Type @Int
Very confused.
I was wrong about thet :type +v
, its only purpose is to show the actual type of the expression, while :type
only shows the type of x in let x = <expr>
. It also seems to always print explicit foralls for some reason. I think the {}
for inferred type variables is supposed to always show up, but it only shows up with -fprint-explicit-foralls
in 8.10.4. However, they do show up without this flag in 9.0.1. I suppose that is a bug of ghci that was fixed in the latest release.
So, the kind variable is actually inferred on 8.10.4:
Prelude GHC.Exts Data.Kind> :set -fprint-explicit-foralls
Prelude GHC.Exts Data.Kind> :t +v proxy#
proxy# :: forall {k} (a :: k). Proxy# a
It is not inferred on 8.8.4:
Prelude GHC.Exts> :t +v proxy#
proxy# :: forall k (a :: k). Proxy# a
Still not sure what made it change
Interesting investigation :) I guess, it's enough to just not use type applications here
bFieldOffsetOf a = fromIntegral (I# (byteFieldOffset (proxy# :: Proxy# name) a))
Also, I'm curious if it's possible to fix the other declaration without using extra variables for better inlining.
So, indeed this fixes GHC 8.10, but there are so many warnings to be addressed, that it will take some time before I upload it to hackage. I've commited your changes slightly modified to compile under earlier versions, so I am closing this PR. Thanks for help!
This fixes the following:
I have no idea how
(proxy# @Symbol @name)
ever worked,proxy#
seems to have only one type argument even in older versions.