Skip to content
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

Expansion of type synonyms is not well kinded #89

Open
RyanGlScott opened this issue Sep 5, 2018 · 0 comments
Open

Expansion of type synonyms is not well kinded #89

RyanGlScott opened this issue Sep 5, 2018 · 0 comments
Labels

Comments

@RyanGlScott
Copy link
Collaborator

I'm not sure if this is a bug that can realistically be fixed, but it did actually bite me recently, so I thought I should report it. Consider the following code:

{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TemplateHaskell #-}
module Bug where

import Data.Kind
import Data.Proxy
import Language.Haskell.TH (pprint, stringE)
import Language.Haskell.TH.Desugar

type MyProxy = (Proxy :: k -> Type)

$(pure [])

test :: String
test = $(expandType (DConT ''MyProxy `DAppT` DConT ''Int) >>= stringE . pprint . typeToTH)

This expands the type synonyms in the type MyProxy Int. However, the result you get is:

λ> test
"(Data.Proxy.Proxy :: k_0 -> *) GHC.Types.Int"

Which is not well kinded. The reason this happens is that when MyProxy is reified during type synonym expansion, a kind signature of k_0 -> Type is placed on it to clarify what its kind argument is. Unfortunately, this later bites us when MyProxy is applied to an argument of kind Type (instead of kind k_0).

I'm not sure what to do here. Should we add a Known Bugs section to the README and mention this there?

@RyanGlScott RyanGlScott added the bug label Sep 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant