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

Promoted classes without Proxy #171

Merged

Conversation

int-index
Copy link
Contributor

@int-index int-index commented Dec 6, 2016

closes #149

In the light of https://ghc.haskell.org/trac/ghc/ticket/12928, I decided to proceed as follows:

  • if a class type variable has no explicit kind, we make no effort to guess it and default to *. This is OK because before TypeInType we were limited by KProxy anyway.
  • if a class type variable has an explicit kind, it is preserved.

This way, we always get CUSKs where we need them.

I also modified promoteType slightly, so this PR closes #145, because now this code compiles:

{-# LANGUAGE TypeInType, ScopedTypeVariables, TypeFamilies, GADTs, TemplateHaskell #-}

import Data.Kind
import Data.Singletons.Promote

$(promote [d|
  class Column (f :: Type -> Type) where
    col :: f a -> a -> Bool
  |])

@int-index int-index force-pushed the promoted-classes-without-proxies-2 branch from e8a79b9 to 60e1f9e Compare December 6, 2016 01:31
@int-index int-index changed the title Promoted classies without Proxy Promoted classes without Proxy Dec 6, 2016
@int-index
Copy link
Contributor Author

Just to make it clear, this version does not remove KindInference constructors.

Copy link
Owner

@goldfirere goldfirere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fantastic. Thanks so much. Do check out my comment in promoteType, though, as I think there's a flat-out error there.

go [] (DVarT name) = return $ DVarT name
go _ (DVarT name) = fail $ "Cannot promote an applied type variable " ++
show name ++ "."
go args (DSigT ty ki) = DSigT <$> go args ty <*> go [] ki
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems wrong. It will treat (x :: k) y as (x y :: k), I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I didn't entirely understand what I was doing here. I'll add a test.

@@ -228,3 +228,6 @@ singDecsM :: DsMonad q => [Dec] -> SgM [DDec] -> q [DDec]
singDecsM locals thing = do
(decs1, decs2) <- singM locals thing
return $ decs1 ++ decs2

proxyFor :: DType -> DExp
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The one use of this function will be able to removed once goldfirere/th-desugar#47 is merged, I think. I don't love the one-off use of the Proxy names here, but it should be temporary enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I intended this function to be temporary, which is why it's in an inappropriate module and uses Proxy names this way. Looking forward to getting rid of it.

@int-index int-index force-pushed the promoted-classes-without-proxies-2 branch from cfc9dba to b5e4091 Compare December 8, 2016 20:53
@int-index int-index force-pushed the promoted-classes-without-proxies-2 branch from b5e4091 to 48e1ee8 Compare December 8, 2016 22:50
@goldfirere goldfirere merged commit f0eddca into goldfirere:master Dec 9, 2016
@goldfirere
Copy link
Owner

Yay! Thanks!

goldfirere pushed a commit that referenced this pull request Dec 9, 2016
@int-index int-index deleted the promoted-classes-without-proxies-2 branch December 9, 2016 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove Proxy from promoted classes Is it possible to promote higher-kinded type classes?
2 participants