derive icon indicating copy to clipboard operation
derive copied to clipboard

Could not convert Type to Kind () ConT GHC.Types.Nat

Open blackgnezdo opened this issue 8 years ago • 1 comments

Derive 2.6.2 running under ghc 8.0.2 reports the following error:

BitR.hs:1:1: error:
    Exception when trying to run compile-time code:
      Could not convert Type to Kind ()
ConT GHC.Types.Nat
derive/v2_6_2/src/Language/Haskell/Convert.hs:(305,5)-(306,57): Non-exhaustive patterns in function conv

CallStack (from HasCallStack):
derive/v2_6_2/src/Language/Haskell/Convert.hs:22:87 in derive:Language.Haskell.Convert
    Code: derive makeNFData ''UInt

When processing the code below:

{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE KindSignatures #-}

import GHC.TypeLits
import Control.DeepSeq(NFData(rnf))
import Data.DeriveTH

newtype Bit (n :: Nat) = Bit { unBit :: Integer }
    deriving (Eq, Ord)

instance (KnownNat n) => NFData (Bit n) where rnf (Bit i) = rnf i

newtype UInt n = UInt (Bit n)
$(derive makeNFData ''UInt)

blackgnezdo avatar Oct 30 '17 19:10 blackgnezdo

Warning: This package has no official maintainer anymore. Use at your own risk. You may wish to consider the built-in mechanism GHC.Generics or libraries such as generic-deriving.

ndmitchell avatar Jul 05 '18 09:07 ndmitchell