-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Locally reified class methods don't explicitly quantify kind variables #88
Comments
If we do fix this, we should be careful to see how |
A similar problem exists for data constructors: {-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
module Main where
import Data.Proxy
import Language.Haskell.TH hiding (Type)
import Language.Haskell.TH.Desugar
main :: IO ()
main = print
$([d| data D (a :: k) = MkD { unD :: Proxy a }
|] >>= \ds -> do
withLocalDeclarations ds (dsReify (mkName "MkD")) >>= runIO . print . show
withLocalDeclarations ds (dsReify (mkName "unD")) >>= runIO . print . show
[| () |])
This time, the kind |
One reason for the kind-dropping in #88 (comment) is because of the definition of th-desugar/Language/Haskell/TH/Desugar/Util.hs Lines 115 to 117 in cb8092f
Yikes. Thankfully, diff --git a/Language/Haskell/TH/Desugar/Util.hs b/Language/Haskell/TH/Desugar/Util.hs
index 2fe6283..5106805 100644
--- a/Language/Haskell/TH/Desugar/Util.hs
+++ b/Language/Haskell/TH/Desugar/Util.hs
@@ -114,7 +114,8 @@ tvbName (KindedTV n _) = n
-- | Convert a 'TyVarBndr' into a 'Type'
tvbToType :: TyVarBndr -> Type
-tvbToType = VarT . tvbName
+tvbToType (PlainTV n) = VarT n
+tvbToType (KindedTV n k) = SigT (VarT n) k
-- | Do two names name the same thing?
nameMatches :: Name -> Name -> Bool That makes the results a little more palatable:
It's still a little unsatisfying, though, since we'd ideally have
In order to preserve the telescope, we'd need an equivalent of |
Thankfully, the |
If you run the following program:
You'll get the following type for
method
:After some cleanup, that's:
This type isn't wrong today, but once ghc-proposals/ghc-proposals#103 is implemented, this will be incorrect, since
k
is implicitly brought into scope in a top-levelforall
.The text was updated successfully, but these errors were encountered: