Abysmal Template Haskell error message
Windows XP
D:\Tools\ghc>ghc-6.2.1\bin\ghc.exe -fglasgow-exts --make foo.hs
Chasing modules from: foo.hs
Compiling Any ( ./Any.hs, ./Any.o )
Compiling Foo ( foo.hs, foo.o )
Loading package base ... linking ... done.
Loading package haskell98 ... linking ... done.
Loading package haskell-src ... linking ... done.
ghc.exe: panic! (the `impossible' happened, GHC version 6.2.1):
Malformed predicate
module Any where
import Language.Haskell.THSyntax
genAny :: DecQ -> Q [Dec]
genAny decl =
do{
d <- decl
; case d of
ClassD _ name _ decls -> sequenceQ [genAnyClass
(name)
decls]
_ -> error "genAny can be applied to classes only"
}
genAnyClass :: String -> [Dec] -> DecQ
genAnyClass name decls =
do{
returnQ (DataD [forall] anyName [] [constructor] [])
}
where
anyName = "Any" ++ name ++ "1111"
constructor = NormalC anyName [(NotStrict, VarT "a")]
forall = ForallT [] [] (VarT "a")
module Foo where
import Any
class MyInterface a where
foo :: a -> Int
foo1 :: Int -> a -> Int
$(genAny (reifyDecl MyInterface))
Edited by Ian Lynagh <igloo@earth.li>