logo       

Template bug 2: msg#00009

lang.haskell.glasgow.bugs

Subject: Template bug 2

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))


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise