
Kim,
I simplified the problem by removing the if then. After that I desugared the
do block to what I think is the equivalent with >> and >>=.
I get the same message (Couldn't match expected type `CGIT IO a0' with
actual type `IO [String]'). I think I do understand where this message is
coming from. But what can I do to fix it?
Kees
module Main(
main
)
where
import Network.CGI
import Text.XHtml
import Text.XHtml.Transitional
import Data.Maybe
runRefreshFirewall :: String -> IO [String]
runRefreshFirewall un = do
return ["test" ]
inputCgiOkPage :: String -> [String] -> Html
inputCgiOkPage un msgs = body << h1 << ("Un: " ++ un)
{--
cgiMain :: CGI CGIResult
cgiMain = do
maybeUn <- getInput "un"
do
msgs <-runRefreshFirewall (fromJust maybeUn)
output $ renderHtml $ (inputCgiOkPage (fromJust maybeUn) msgs)
--}
cgiMain :: CGI CGIResult
cgiMain = (getInput "un") >>= \maybeUn -> (runRefreshFirewall (fromJust
maybeUn) >>=
\msgs -> (output $ renderHtml $ inputCgiOkPage
(fromJust maybeUn) msgs))
main :: IO ()
main = runCGI $ handleErrors cgiMain
Van: Beginners [mailto:beginners-bounces@haskell.org] Namens Kim-Ee Yeoh
Verzonden: maandag 14 oktober 2013 14:58
Aan: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell
Onderwerp: Re: [Haskell-beginners] monads do not fit together?
On Mon, Oct 14, 2013 at 6:51 PM, Kees Bleijenberg