Converting an IO String to a Response

3 views
Skip to first unread message

deech

unread,
Jun 16, 2009, 3:02:04 PM6/16/09
to HAppS
Hi all,
How do I return an IO String on a POST request? Currently I have:

appHandler = dir "testIO" returnString

returnString = methodM POST >>
return $ toResponse $ ioString "hello world"

ioString :: String -> IO String
ioString s = return s

And I get an error saying that an IO String cannot be converted to a
Response. How do I get this to work?

thanks ...
-deech

Jake McArthur

unread,
Jun 16, 2009, 3:14:32 PM6/16/09
to HA...@googlegroups.com
deech wrote:
> returnString = methodM POST >>
> return $ toResponse $ ioString "hello world"
>
> ioString :: String -> IO String
> ioString s = return s
>
> And I get an error saying that an IO String cannot be converted to a
> Response. How do I get this to work?

You can't convert an IO String to a Response, but you *can* convert a
(String -> Response) to a (IO String -> IO Response):

returnString = methodM POST >>
liftIO $ toResponse <$> ioString "hello world"

- Jake

Reply all
Reply to author
Forward
0 new messages