Ticket #82 (new enhancement)

Opened 5 years ago

Last modified 22 months ago

Comments inside record field types

Reported by: SamB Owned by:
Priority: minor Milestone:
Version: Keywords:
Cc: SamB, mmitar@…

Description

for some reason,

newtype P a = P { runP ::
                        String          -- ^ Input string
                     -> Int             -- ^ Current column
                     -> Int             -- ^ Current line
                     -> SrcLoc          -- ^ Location of last token read
                     -> ParseState      -- ^ Layout info.
                     -> ParseMode       -- ^ Parse parameters
                     -> ParseStatus a
                }

fails to parse, but

newtype P a = P { runP ::
                        String          -- Input string
                     -> Int             -- Current column
                     -> Int             -- Current line
                     -> SrcLoc          -- Location of last token read
                     -> ParseState      -- Layout info.
                     -> ParseMode       -- Parse parameters
                     -> ParseStatus a
                }

parses fine.

Change History

  Changed 5 years ago by waern

This is just not supported by the current grammar. It would be nice to support it, but I wonder how, since it is possible to comment record fields using the -- ^ notation which would clash with commenting the result type.

Perhaps we should only allow comments on record fields to exist on the lines before or after the field. This would make it possible to comment the type (or parts of the type) like you did in the example.

follow-up: ↓ 4   Changed 5 years ago by SamB

Yeah, I figured that out soon after posting this ;-). Personally, I'd be happy with this requiring the function type to be in parens. (A nicer parse error would also be helpful.) I guess this bug is misnamed ... did you already make a bug about this?

  Changed 5 years ago by SamB

  • cc SamB added

in reply to: ↑ 2   Changed 5 years ago by waern

Replying to SamB:

Yeah, I figured that out soon after posting this ;-). Personally, I'd be happy with this requiring the function type to be in parens.

Hmm, that's a bit inconsistent though, since comments on types of function definitions works exactly the opposite way.

(A nicer parse error would also be helpful.) I guess this bug is misnamed ... did you already make a bug about this?

Nope, there's no such bug report. I'd rather call it an enhancement though, since the comments-on-types stuff has a very limited design currently and was not supposed to do this. It for example only supports comments on function arguments at the highest level. I think it would be good to try to generalize the design a little bit to support cases like this and more.

  Changed 5 years ago by waern

  • priority changed from major to minor
  • type changed from defect to enhancement
  • summary changed from Strange layout bug to Comments inside record field types

  Changed 4 years ago by mitar

  • cc mmitar@… added

  Changed 22 months ago by anonymous

  • milestone 2.5.0 deleted

Milestone 2.5.0 deleted

Note: See TracTickets for help on using tickets.