Use Template Haskell recover inside the IO monad

28 Feb
2012
28 Feb
'12
3:59 p.m.
I'm new to Template Haskell and just started playing with it. I have Haskell platform 2011.4.0 and I get this error when I try to run this simple code. main = do code <- runQ $ recover (return []) th putStrLn (pprint code) putStrLn (show code) th :: Q [Dec] th = [d| sum a b = a + b |] Template Haskell error: Can't do `recover' in the IO monad POC.hs: user error (Template Haskell failure) How can I get declarations with the "recover" function so I can print a custom error message using "location"? If I can't do it inside the IO monad, how can I do a program to pretty print Haskell code? Thanks!
4831
Age (days ago)
4831
Last active (days ago)
0 comments
1 participants
participants (1)
-
Federico Mastellone