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

PolyKinds breaks phantom newtype deriving with non obvious error message #83

Open
yaitskov opened this issue Mar 11, 2021 · 2 comments
Open

Comments

@yaitskov
Copy link

Hi,

I am upgrading SafeCopy to version 0.10.4.1 and discovered following
unpleased behavior. Mostly I concerned with stumbling error message.

{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveAnyClass #-}

module Main where

import           Data.SafeCopy
import           Data.Serialize  
import           GHC.Generics 
import           Type.Reflection 
import           Prelude


newtype IntKey r = IntKey { intKey :: Int } deriving (Show, Eq, Generic, Serialize, Typeable)

instance Typeable r => SafeCopy (IntKey r)

The snipped above is just fine until I enable PolyKinds extension.
Error message makes impression like GHC is incapable to do the obvious thing!

    • Could not deduce (Typeable k)
        arising from the superclasses of an instance declaration
      from the context: Typeable r
        bound by the instance declaration
        at Main.hs:31:10-43
    • In the instance declaration for ‘SafeCopy (IntKey r)’
   |
31 | instance Typeable r => SafeCopy (IntKey r)

@stepcut
Copy link
Member

stepcut commented Mar 11, 2021

Does this code work with PolyKinds enabled in older versions of safecopy ?

From your report it is not clear if it used it work in older version of safecopy, and upgrading broke things.

@ddssff
Copy link
Collaborator

ddssff commented Mar 11, 2021

Not surprisingly, this works: instance Typeable (r :: *) => SafeCopy (IntKey r), I can't think of a way to do this in the library code off the top of my head. I does seem my version bump was too optimistic.

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

No branches or pull requests

3 participants