7 Sep 2011 21:50
change in [d| |] and creating instances in template-haskell 2.7
Jeremy Shaw <jeremy <at> n-heptane.com>
2011-09-07 19:50:03 GMT
2011-09-07 19:50:03 GMT
Hello,
I have some code that likes like this, which works in template-haskell
2.5 / GHC 7.0.3:
---------------
{-# Language TemplateHaskell, TypeFamilies #-}
module Show where
import Language.Haskell.TH
class Bar a where
bar :: a -> String
inferBar :: Name -> Q [Dec]
inferBar typeName =
do s <- [d| bar _ = "sucker"
|]
d <- instanceD (return []) (appT (conT ''Bar) (conT typeName))
(map return s)
return [d]
-----------------
$(inferBar ''Bool)
But, in template-haskell 2.6 / GHC 7.2.1, I get an error,
Warning: No explicit method nor default method for `bar'
In the instance declaration for `Bar Bool'
(Continue reading)
RSS Feed