Skip to content

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

Description

@yaitskov

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions