[GHC] #8226: Remove the old style -- # Haddock comments.

#8226: Remove the old style -- # Haddock comments. ------------------------------------+------------------------------------- Reporter: Fuuzetsu | Owner: Type: task | Status: new Priority: normal | Milestone: 7.8.1 Component: Compiler | Version: 7.7 Keywords: | Operating System: Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: None/Unknown Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | ------------------------------------+------------------------------------- Haddock 0.x supported -- # style comments for Haddock pragma and while this seems to have been long forgotten and not documented, it's still kicking in the lexer. I think this is a good time to get rid of these all together. Relevant Haddock ticket http://trac.haskell.org/haddock/ticket/171 I'll hopefully send in patches removing these from the lexer/parser tomorrow, if all goes well (unless anyone feels eager to do it, then please, you're most welcome to do so!). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8226 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8226: Remove the old style -- # Haddock comments. -------------------------------------+------------------------------------ Reporter: Fuuzetsu | Owner: Type: task | Status: new Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by adinapoli): (Rewriting comment that the tracker wiped :'( ) In a nutshell this is my first session of GHC hacking ever, so please be patient if - as I'm certain - my patch doesn't fully fix the issue or is going in the wrong direction. I have manually tested the fix modifying slightly the testcase attached to the relevant haddock ticket: http://trac.haskell.org/haddock/ticket/171 {{{ {- # LANGUAGE RecordWildCards #-} module Fail where data Foo = Foo { a :: String , b :: Int } showFoo Foo{..} = a main :: IO () main = print $ showFoo (Foo "a" 10) }}} As pointed out that one is _not_ a pragma (mind the space), so it needs to be interpreted as a normal comment, but Haddock chokes on it: {{{ -- pre-fix [nix-shell:ghc]$ ghc -haddock Fail.hs [1 of 1] Compiling Main ( Fail.hs, Fail.o ) Fail.hs:1:4: parse error on input ‘#’ }}} But after my patch it seems to accept it: {{{ [nix-shell:ghc]$ ghc-dev -haddock Fail.hs [1 of 1] Compiling Fail ( Fail.hs, Fail.o ) Fail.hs:10:9: Illegal `..' in record pattern Use RecordWildCards to permit this }}} I have ran "validate" before and after the patch and it seems no regression was introduces, but being the Lexer such a delicate part I really want to be cautious with it :) Thanks guys, hope I'm on the right track :) Alfredo -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8226#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8226: Remove the old style -- # Haddock comments. -------------------------------------+------------------------------------ Reporter: Fuuzetsu | Owner: Type: task | Status: new Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by simonpj): It'd be great if a Haddock-aware person was able to take a look. Thanks. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8226#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8226: Remove the old style -- # Haddock comments. -------------------------------------+------------------------------------ Reporter: Fuuzetsu | Owner: Type: task | Status: patch Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Changes (by adinapoli): * status: new => patch -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8226#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8226: Remove the old style -- # Haddock comments. -------------------------------------+------------------------------------ Reporter: Fuuzetsu | Owner: Type: task | Status: patch Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by Fuuzetsu): Sorry I fell behind a bit on reading GHC tickets. Yes adinapoli, those should also be removed, we do not use --# for anything and it served the same purpose as {-# as far as I know. Also the data type used to store that type of comment should be removed: https://github.com/ghc/ghc/blob/master/compiler/parser/Lexer.x#L625 FTR the Haddock ticket is now tracked at https://github.com/haskell/haddock/issues/171 Thanks for looking into this, feel free to poke me on IRC/e-mail if you need more immediate review. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8226#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8226: Remove the old style -- # Haddock comments. -------------------------------------+------------------------------------ Reporter: Fuuzetsu | Owner: adinapoli Type: task | Status: patch Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Changes (by adinapoli): * owner: => adinapoli -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8226#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8226: Remove the old style -- # Haddock comments. -------------------------------------+------------------------------------ Reporter: Fuuzetsu | Owner: adinapoli Type: task | Status: patch Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by adinapoli): Hi guys, I haven't forgot, is that I'm making basically no progress on it. After Fuuzetsu's suggestion of removing the old data structure which held the 0.x style comments, I stumbled upon a series of difficulties, which are, unordered, the result of different edits on the Lexer; * Removing the data structure caused immediately GHC to complain on old style comments which are actually leftovers, an example is inside libraries/ghc-prim/GHC/Classes.hs. I couldn't understand from the sole documentation what to do, but it seems to me that, as Fuuzetsu said, they can be removed because they are equivalent to a pragma (in the example -- #hide == {-# OPTIONS_HADDOCK hide #-}. Unfortunately the lexer chokes in trying to parse "-- #hide" once the data structure has been removed, even though, theoretically, should be possible to modify the Lexer to just treat them as a normal comment ; after all the only thing which prevents this to happen, I believe, is the "isNormalComment" function. Unfortunately I can't modify it as per my first patch (aka removing the "#") because this will cause GHC to interpret RULES as normal comments (I discovered this thanks to an insight from SPJ). Sorry for the noise, I thought it was worth documenting my efforts my myself in the future :) If someone has some insights, please shout :) Alfredo -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8226#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8226: Remove the old style -- # Haddock comments.
-------------------------------------+------------------------------------
Reporter: Fuuzetsu | Owner: adinapoli
Type: task | Status: patch
Priority: normal | Milestone: 7.10.1
Component: Compiler | Version: 7.7
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture: Unknown/Multiple
Type of failure: None/Unknown | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets:
-------------------------------------+------------------------------------
Comment (by Fuuzetsu):
Hm, I'm unsure why this is proving difficult to implement. Looking at the
lexer, it seems that it should be enough to:
* Remove {{{#}}} from any sections lexing Haddock comment so sections like
{{{[$docSym \#]}}} become just {{{[$docSym]}}} or whatever the appropriate
syntax is there.
* in {{{

#8226: Remove the old style -- # Haddock comments. -------------------------------------+------------------------------------ Reporter: Fuuzetsu | Owner: Type: task | Status: new Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Changes (by Fuuzetsu): * owner: adinapoli => * status: patch => new -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8226#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8226: Remove the old style -- # Haddock comments. -------------------------------------+------------------------------------ Reporter: Fuuzetsu | Owner: adinapoli Type: task | Status: new Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Changes (by Fuuzetsu): * owner: => adinapoli -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8226#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8226: Remove the old style -- # Haddock comments. -------------------------------------+------------------------------------ Reporter: Fuuzetsu | Owner: adinapoli Type: task | Status: new Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by adinapoli): Replying to [comment:8 Fuuzetsu]:
Hm, I'm unsure why this is proving difficult to implement.
Oh, it's easy, that's because it's my first foray into GHC and its Lexer hacking ever :)
* Remove {{{#}}} from any sections lexing Haddock comment so sections
like {{{[$docSym \#]}}} become just {{{[$docSym]}}} or whatever the appropriate syntax is there.
* in {{{
}}} remove the lexing of {{{-- #}}} all together. * Remove {{{ITdocOptionsOld}}}.
* inside {{{isNormalComment}}}, I'm unsure exactly how to proceed. You
say removing {{{#}}} from {{{notFollowedByDocOrPragma}}} stops {{{RULES}}} from working. In that case I say keep it there as it is now, in the end it does not matter because we'll stop treating it as a Haddock thing anyway. It will now simply check whether a {{{#}}} comment is special for {{{RULES}}} instead of for both {{{RULES}}} and Haddock. This is an assumption however so this might be where I'm going wrong.
* {{{withLexedDocType}}} remove the case for {{{'#'}}}: if we removed
the case for {{{-- #}}} in {{{
* Remove the case in for {{{ITdocOptionsOld}}} in {{{getOptions'}}} in
{{{HeaderInfo.hs}}}.
Apart from the docSym section I already tried was you said, with no luck. This is a gist to a patch which follows your guidelines; unless I have tweaked the wrong things, it should roughly do what you listed: https://gist.github.com/adinapoli/a08683a32412c8fddb43 This validates fine but it doesn't fix the problem! If I try the "Fail.hs" example attached in the ticket, the Lexer still chokes on that comment which "looks like a pragma". But originally my fix on "isNormalComment" fixed that, but amusingly if I tweak that function, as part of this patch, it triggers the problem I've reported, aka the RULES gets interpreted as comments and validate fails due to warnings for unutilized functions. Where's the flaw in my reasoning? :)
PS: It'd be great if you could create a wiki page (either on GHC wiki or NixOS wiki) on your workflow on GHC hacking with nix.
More than happy to do so, didn't think was something people would have been interested in :) Alfredo -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8226#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8226: Remove the old style -- # Haddock comments. -------------------------------------+------------------------------------- Reporter: Fuuzetsu | Owner: adinapoli Type: task | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.7 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by harpocrates): * status: new => closed * resolution: => fixed Comment: This was fixed a couple years ago in 2f733b3a4b95a35dfdd43915afec9f0f615edacd. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8226#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC