How to use “IO String” as an HTTP response in Happstack?
问题 I'm retrieving data from a database using HDBC, then trying to send this data to a web client using Happstack. myFunc :: Integer -> IO String myFunc = ... fetch from db here ... handlers :: ServerPart Response handlers = do decodeBody (defaultBodyPolicy "/tmp/" 0 1000 1000) msum [ dir "getData" $ ok $ toResponse $ myFunc $ toInteger 1 ] mainFunc = simpleHTTP nullConf handlers When I build the above code I get this error: No instance for (ToMessage (IO String)) arising from a use of