<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Ben Gamari is, I believe, leading the effort with that proposal. It continues to get attention but has not yet blossomed to something we're ready to debate widely. This is a hard nut to crack, and we'd like to get it right. So I guess all there is to say right now is that the effort is ongoing, but we don't have anything concrete to report at the moment.<div class=""><br class=""></div><div class="">Richard<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Oct 23, 2019, at 7:52 AM, Javier Neira Sanchez <<a href="mailto:atreyu.bbb@gmail.com" class="">atreyu.bbb@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="auto" class=""><div style="font-family:sans-serif;font-size:12.8px" dir="auto" class=""><div style="width:328px;margin:16px 0px" class=""><div class=""><div class=""><font size="-1" class=""><font face="Verdana" class="">Hi, lately i am being collaborated in the haskell-ide-engine (hie) repo and one of the issues i get to fix was related with the parsing of ghc errors.<br class="">It turns out that delimiters of terms in errors are different in windows (`term') and *nix (‘term’) systems and that drive to parse errors.<br class="">Quite code actions and diagnostics are based in parsing them and they were broken in windows.<br class="">I am afraid that the code is very brittle and close to human readable error messages. the actual code look like this:<br class=""><br class=""></font></font><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">-- | Extract a term from a compiler message.</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">-- It looks for terms delimited between '‘' and '’' falling back to '`' and '\''</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">-- (the used ones in Windows systems).</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">extractTerm :: T.Text -> T.Text</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">extractTerm txt =</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">  case extract '‘' '’' txt of</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">    ""  -> extract '`' '\'' txt -- Needed for windows</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">    term -> term</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">  where extract b e = T.dropWhile (== b)</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">                    . T.dropWhileEnd (== e)</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">                    . T.dropAround (\c -> c /= b && c /= e)

</font></font>
</pre><font size="-1" class=""><font face="Verdana" class="">or<br class=""><br class=""></font></font><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">extractImportableTerm :: T.Text -> Maybe (T.Text, SymbolImport SymbolType)</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">extractImportableTerm dirtyMsg = do</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">  (n, s) <- extractedTerm</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">  let n' = T.strip n</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">  return (n', s)</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">  where</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">    importMsg = S.headMay</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">      -- Get rid of the rename suggestion parts</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">      $ T.splitOn "Perhaps you meant "</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">      $ T.replace "\n" " "</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">      -- Get rid of trailing/leading whitespace on each individual line</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">      $ T.unlines</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">      $ map T.strip</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">      $ T.lines</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">      $ T.replace "* " "" -- Needed for Windows</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">      $ T.replace "• " "" dirtyMsg</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">    extractTerm prefix symTy =</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">      importMsg</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">          >>= T.stripPrefix prefix</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">          >>= \name -> Just (name, Import symTy)</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">    extractType b =</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">      extractTerm ("Not in scope: type constructor or class " <> b) Type</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">    extractedTerm = asum</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">      [ extractTerm "Variable not in scope: " Symbol</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">      , extractType "‘"</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">      , extractType "`" -- Needed for windows</font></font></pre><pre style="white-space:pre-wrap" class=""><font size="-1" class=""><font face="Verdana" class="">      , extractTerm "Data constructor not in scope: " Constructor]</font></font></pre><font size="-1" class=""><font face="Verdana" class=""><br class="">It is clearly unsatisfactory but hard to improve without changing the messages to make it more structured.<br class="">Moreover any legitimate change on errors to make it better will likely break it.<br class=""><br class="">After exposing my worries in the hie irc channel, @mpickering pointed out that it is already a proposal to improve error messages:<br class=""></font></font><br class=""><a href="https://github.com/bgamari/ghc-proposals/blob/rich-errors-proposal/proposals/0000-rich-errors-proposal.rst" style="text-decoration-line:none;color:rgb(66,133,244)" class="">https://github.com/bgamari/ghc-proposals/blob/rich-errors-proposal/proposals/0000-rich-errors-proposal.rst</a><br class=""><br class="">that nicely will improve the state of things.<br class=""><br class="">Otoh there are already a way to output ghc errors as json (see <a href="https://gitlab.haskell.org/ghc/ghc/issues/13190" style="text-decoration-line:none;color:rgb(66,133,244)" class="">https://gitlab.haskell.org/ghc/ghc/issues/13190</a>). It contains valuable info about the error in specific fields but the message itself is in plain text.<br class="">So merging both features will let tools to handle compiler errors without use the ghc api directly if needed.<br class=""><br class="">what is the status of the proposal? hie an other tooling developers will welcome it very heartly.<br class=""><br class="">Thanks in advance!<br class=""></div></div></div></div></div>
_______________________________________________<br class="">ghc-devs mailing list<br class=""><a href="mailto:ghc-devs@haskell.org" class="">ghc-devs@haskell.org</a><br class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs<br class=""></div></blockquote></div><br class=""></div></body></html>