<div dir="ltr">Hello all,<div><br></div><div>I figured out that this isn't quite a bug and figured out how to do what I wanted. It turns out that the `Show` instance for SourceError does not respect `pprCols` - I don't know if that's a reasonable expectation (although it's what I expected). I ended up using the following code to print these messages:</div>

<div><br></div><div><div><font face="courier new, monospace">  flip gcatch handler $ do</font></div><div><font face="courier new, monospace">    runStmt "let f (x, y, z, w, e, r, d , ax, b ,c,ex ,g ,h) = (x :: Int) + y + z" RunToCompletion</font></div>

<div><font face="courier new, monospace">    runStmt "f (1, 2, 3)" RunToCompletion</font></div><div><font face="courier new, monospace">    return ()</font></div><div><font face="courier new, monospace">  where</font></div>

<div><font face="courier new, monospace">    handler :: SourceError -> Ghc ()</font></div><div><font face="courier new, monospace">    handler srcerr = do</font></div><div><font face="courier new, monospace">      let msgs = bagToList $ srcErrorMessages srcerr</font></div>

<div><font face="courier new, monospace">      forM_ msgs $ \msg -> do</font></div><div><font face="courier new, monospace">        s <- doc $ errMsgShortDoc msg </font></div><div><font face="courier new, monospace">        liftIO $ putStrLn s</font></div>

<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">doc :: GhcMonad m => SDoc -> m String</font></div><div><font face="courier new, monospace">doc sdoc = do</font></div>

<div><font face="courier new, monospace">  flags <- getSessionDynFlags</font></div><div><font face="courier new, monospace">  let cols = pprCols flags</font></div><div><font face="courier new, monospace">      d = runSDoc sdoc (initSDocContext flags defaultUserStyle)</font></div>

<div><font face="courier new, monospace">  return $ Pretty.fullRender Pretty.PageMode cols 1.5 string_txt "" d</font></div><div><font face="courier new, monospace">  where</font></div><div><font face="courier new, monospace">    string_txt :: Pretty.TextDetails -> String -> String</font></div>

<div><font face="courier new, monospace">    string_txt (Pretty.Chr c)   s  = c:s</font></div><div><font face="courier new, monospace">    string_txt (Pretty.Str s1)  s2 = s1 ++ s2</font></div><div><font face="courier new, monospace">    string_txt (Pretty.PStr s1) s2 = unpackFS s1 ++ s2</font></div>

<div><font face="courier new, monospace">    string_txt (Pretty.LStr s1 _) s2 = unpackLitString s1 ++ s2</font></div></div><div><br></div><div>As far as I can tell, there is no simpler way, every function in `Pretty` except for `fullRender` just assumes a default of 100-char lines.</div>

<div><br></div><div>-- Andrew</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jan 7, 2014 at 11:29 AM, Andrew Gibiansky <span dir="ltr"><<a href="mailto:andrew.gibiansky@gmail.com" target="_blank">andrew.gibiansky@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Simon,<div><br></div><div>That's exactly what I'm looking for! But it seems that doing it dynamically in the GHC API doesn't work (as in my first email where I tried to adjust pprCols via setSessionDynFlags).</div>


<div><br></div><div>I'm going to look into the source as what ppr-cols=N actually sets and probably file a bug - because this seems like buggy behaviour...</div><span class="HOEnZb"><font color="#888888"><div><br></div>

<div>Andrew</div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra">
<br><br><div class="gmail_quote">On Tue, Jan 7, 2014 at 4:14 AM, Simon Peyton Jones <span dir="ltr"><<a href="mailto:simonpj@microsoft.com" target="_blank">simonpj@microsoft.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">








<div lang="EN-GB" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#1f497d">-dppr-cols=N changes the width of the output page; you could try a large number there.  There isn’t a setting meaning “infinity”, sadly.<u></u><u></u></span></p>



<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#1f497d">Simon<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif""> Andrew Gibiansky [mailto:<a href="mailto:andrew.gibiansky@gmail.com" target="_blank">andrew.gibiansky@gmail.com</a>]
<br>
<b>Sent:</b> 07 January 2014 03:04<br>
<b>To:</b> Simon Peyton Jones<br>
<b>Cc:</b> Erik de Castro Lopo; <a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a></span></p><div><div><br>
<b>Subject:</b> Re: Changing GHC Error Message Wrapping<u></u><u></u></div></div><p></p>
</div>
</div><div><div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">Thanks Simon.<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">In general I think multiline tuples should have many elements per line, but honestly the tuple case was a very specific example. If possible, I'd like to change the *overall* wrapping for *all* error messages - how does `sep` know when
 to break lines? there's clearly a numeric value for the number of columns somewhere, but where is it, and is it user-adjustable?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">For now I am just hacking around this by special-casing some error messages and "un-doing" the line wrapping by parsing the messages and joining lines back together.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Thanks,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Andrew<u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Mon, Jan 6, 2014 at 7:44 AM, Simon Peyton-Jones <<a href="mailto:simonpj@microsoft.com" target="_blank">simonpj@microsoft.com</a>> wrote:<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#1f497d">I think it’s line 705 in types/TypeRep.lhs</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36.0pt">
<span style="font-family:"Calibri","sans-serif";color:#1f497d">pprTcApp p pp tc tys</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36.0pt">
<span style="font-family:"Calibri","sans-serif";color:#1f497d">  | isTupleTyCon tc && tyConArity tc == length tys</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36.0pt">
<span style="font-family:"Calibri","sans-serif";color:#1f497d">  = pprPromotionQuote tc <></span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36.0pt">
<span style="font-family:"Calibri","sans-serif";color:#1f497d">    tupleParens (tupleTyConSort tc) (sep (punctuate comma (map (pp TopPrec) tys)))</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#1f497d">If you change ‘sep’ to ‘fsep’, you’ll get behaviour more akin to paragraph-filling (hence the “f”).   Give it a try. 
 You’ll get validation failure from the testsuite, but you can see whether you think the result is better or worse.  In general, should multi-line tuples be printed with many elements per line, or just one?</span><u></u><u></u></p>



<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#1f497d">Simon</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif"">
 ghc-devs [mailto:<a href="mailto:ghc-devs-bounces@haskell.org" target="_blank">ghc-devs-bounces@haskell.org</a>]
<b>On Behalf Of </b>Andrew Gibiansky<br>
<b>Sent:</b> 04 January 2014 17:30<br>
<b>To:</b> Erik de Castro Lopo<br>
<b>Cc:</b> <a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<b>Subject:</b> Re: Changing GHC Error Message Wrapping</span><u></u><u></u></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">Apologize for the broken image formatting.<u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">With the code I posted above, I get the following output:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">Couldn't match expected type `(<a href="http://GHC.Types.Int" target="_blank">GHC.Types.Int</a>,</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">                               <a href="http://GHC.Types.Int" target="_blank">GHC.Types.Int</a>,</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">                               <a href="http://GHC.Types.Int" target="_blank">GHC.Types.Int</a>,</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">                               t0,</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">                               t10,</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">                               t20,</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">                               t30,</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">                               t40,</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">                               t50,</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">                               t60,</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">                               t70,</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">                               t80,</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">                               t90)'</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">            with actual type `(t1, t2, t3)'</span><u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">I would like the types to be on the same line, or at least wrapped to a larger number of columns.</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">Does  anyone know how to do this, or where in the GHC source this wrapping is done?</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">Thanks!</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">Andrew</span><u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"> <u></u><u></u></p>
<div>
<p class="MsoNormal">On Sat, Jan 4, 2014 at 2:55 AM, Erik de Castro Lopo <<a href="mailto:mle+hs@mega-nerd.com" target="_blank">mle+hs@mega-nerd.com</a>> wrote:<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt">
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Carter Schonwald wrote:<br>
<br>
> hey andrew, your image link isn't working (i'm using gmail)<u></u><u></u></p>
</div>
<p class="MsoNormal">I think the list software filters out image attachments.<br>
<span style="color:#888888"><br>
Erik<br>
--<br>
----------------------------------------------------------------------<br>
Erik de Castro Lopo<br>
<a href="http://www.mega-nerd.com/" target="_blank">http://www.mega-nerd.com/</a></span><u></u><u></u></p>
<div>
<div>
<p class="MsoNormal">_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/ghc-devs" target="_blank">http://www.haskell.org/mailman/listinfo/ghc-devs</a><u></u><u></u></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div></div></div>
</div>
</div>

</blockquote></div><br></div>
</div></div></blockquote></div><br></div>