Hi,<br><br>Could someone please care to explain what I am doing wrong below in cgiMain2 and how can I fix it?<br><br><br>./Main.hs:25:15:<br>&nbsp;&nbsp;&nbsp; No instance for (MonadCGI IO)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; arising from a use of `output&#39; at ./Main.hs:25:15-20<br>
&nbsp;&nbsp;&nbsp; Possible fix: add an instance declaration for (MonadCGI IO)<br>&nbsp;&nbsp;&nbsp; In the first argument of `($)&#39;, namely `output&#39;<br>&nbsp;&nbsp;&nbsp; In the expression: output $ renderHtml $ page &quot;import&quot; fileForm<br>&nbsp;&nbsp;&nbsp; In the definition of `upload&#39;:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; upload = output $ renderHtml $ page &quot;import&quot; fileForm<br><br>./Main.hs:57:29:<br>&nbsp;&nbsp;&nbsp; Couldn&#39;t match expected type `CGI CGIResult&#39;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; against inferred type `IO CGIResult&#39;<br>&nbsp;&nbsp;&nbsp; In the first argument of `handleErrors&#39;, namely `cgiMain2&#39;<br>
&nbsp;&nbsp;&nbsp; In the second argument of `($)&#39;, namely `handleErrors cgiMain2&#39;<br>&nbsp;&nbsp;&nbsp; In the expression: runCGI $ handleErrors cgiMain2<br><br><br><span style="font-family: courier new,monospace;">import IO</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">import Network.CGI</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">import Text.XHtml</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">import qualified Data.ByteString.Lazy as BS</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">import Control.Monad (liftM)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">import Data.Maybe (fromJust)</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">import Interact</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">fileForm = form ! [method &quot;post&quot;, enctype &quot;multipart/form-data&quot;] &lt;&lt;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [afile &quot;file&quot;, submit &quot;&quot; &quot;Upload&quot;]</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">page t b = header &lt;&lt; thetitle &lt;&lt; t +++ body &lt;&lt; b</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">cgiMain1 = do</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp; getInputFPS &quot;file&quot; ↠ λms → maybe upload contents ms ↠ return</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp; where</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; upload&nbsp;&nbsp; = output $ renderHtml $ page &quot;import&quot; fileForm</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; contents = outputFPS</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">cgiMain2 = do</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp; getInputFPS &quot;file&quot; ↠ λms → maybe upload contents ms ↠ return</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp; where</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; upload&nbsp;&nbsp; = output $ renderHtml $ page &quot;import&quot; fileForm</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; contents = λs → do</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (i,o,h,_) ← runUnzip&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BS.hPutStr i s</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; c ← BS.hGetContents o</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; outputFPS c</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">{-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (i,o,h,_) ← runUnzip</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BS.hPutStr i s</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BS.hGetContents o ↠ outputFPS</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">-}</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">{-</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">liftM :: (Monad m) =&gt; (a1 -&gt; r) -&gt; m a1 -&gt; m r</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">liftIO :: (MonadIO m) =&gt; IO a -&gt; m a</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">saveFile n =</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; do cont &lt;- liftM fromJust $ getInputFPS &quot;file&quot;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; let f = uploadDir ++ &quot;/&quot; ++ basename n</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; liftIO $ BS.writeFile f cont</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return $ paragraph &lt;&lt; (&quot;Saved as &quot; +++ anchor ! [href f] &lt;&lt; f +++ &quot;.&quot;)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">-}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">runUnzip = runInteractiveCommand &quot;unzip -l /dev/stdin&quot;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">main = runCGI $ handleErrors cgiMain2</span><br><br><span style="font-family: times new roman,serif;">Best Regards,<br>
Cetin Sert<br><br>P/s: what are lifts o_O?<br></span>