liveBook · Manning

Comment

As explained in Learn Haskell by Example

A comment is non-data text embedded in a file format and delimited according to that format's syntax.

A comment is non-data text embedded in a file format. In a PNM header, it starts with % and continues until a newline, so the parser can discard it while reading image metadata. section 12.2.2

Parsing PNM comments

With Attoparsec, read the opening marker with char '%' and consume the remaining characters with takeWhile (/= '\n'). Because comments may appear between header values, combine the comment parser with whitespace handling and recurse until neither is present.

How Learn Haskell by Example covers it

How deep it goes
Implements comment recognition and recursive skipping alongside whitespace, without treating comment contents as data.
Examples
Uses percent-prefixed PNM header comments consumed through a newline by an Attoparsec parser.
What you can do after
Build it from scratch with Attoparsec by recognizing comments and ignoring them between PNM header fields.
How it connects
Connects comments with whitespace, parser combinators, PNM headers, and Attoparsec.

Also explained in

Compare how 2 books explain comment →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Haskell by Example. The section links point to the parts of the book it draws on.