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

Could not convert Dec to Decl () #29

Open
blackgnezdo opened this issue Oct 31, 2017 · 2 comments
Open

Could not convert Dec to Decl () #29

blackgnezdo opened this issue Oct 31, 2017 · 2 comments

Comments

@blackgnezdo
Copy link

blackgnezdo commented Oct 31, 2017

Running derive/v2_6_2 with GHC8 I'm getting this error:

Bug2.hs:1:1: error:
    Exception when trying to run compile-time code:
      Could not convert Dec to Decl ()
TySynD Main.NewType [] (ConT Main.DataType)
derive/v2_6_2/src/Language/Haskell/Convert.hs:(41,14)-(45,8): Non-exhaustive patterns in case

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

for the code below:

{-# LANGUAGE TemplateHaskell #-}

import Control.DeepSeq(NFData(..))
import Data.DeriveTH

type NewType = DataType
data DataType = DataType
$(derive makeNFData ''NewType)

Admittedly deriving something for a type is not exactly the best idea, but a more helpful error would be nice.

@blackgnezdo
Copy link
Author

Come to think of it, the issue is not in fact silly. In full code my data is parameterized by a type family. So I do need to derive the instance for the type Type = DataType Identity. Making this work is a functional requirement.

FWIW, this workaround kind of works, but I loathe mixing different styles of NFData:

deriving instance Generic Type
instance NFData Type

@ndmitchell
Copy link
Owner

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.

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

2 participants