Skip to content

Document readFields - #8983

Closed
phadej wants to merge 3 commits into
haskell:masterfrom
phadej:document-readFields
Closed

phadej wants to merge 3 commits into
haskell:masterfrom
phadej:document-readFields

Conversation

@phadej

@phadej phadej commented May 30, 2023 •

Copy link
Copy Markdown
Collaborator

This PR cherry-picks a lexer BOM/NBSP commit from #8975.

The last commit documents readFields:

Document that readFields expects input to be UTF8

For example parseGenericPackageDescription validates input it passes to readFields'.

That is desirable: we want try to parse non-UTF8 inputs, and report as a warning if they are not UTF8. (There are non-UTF8 .cabal files on Hackage, e.g. with German names).

In some other world lexer could repair invalid UTF8 on the fly, but OTOH it's quite simple to just do a prepass, as lexer makes (most of its) decisions on ASCII characters, and can treat text parts as opaque bytes.

This last commit doesn't change anything, it simply documents the current state of the codebase.

phadej added 3 commits May 29, 2023 19:37
As it runs fourmolu only on modified files, it's a lot faster.
For example `parseGenericPackageDescription` validates input it passes to `readFields'`.

That is desirable: we want try to parse non-UTF8 inputs, and report as a warning if they are not UTF8. (There are non-UTF8 .cabal files on Hackage, e.g. with German names).
@Kleidukos

Copy link
Copy Markdown
Member

(There are non-UTF8 .cabal files on Hackage, e.g. with German names).

What is their encoding then? ISO 8859-2?

@phadej

phadej commented May 30, 2023

Copy link
Copy Markdown
Collaborator Author

(There are non-UTF8 .cabal files on Hackage, e.g. with German names).

What is their encoding then? ISO 8859-2?

I don't know. Maybe Latin1, maybe something else. Actually right now I can find only one file: https://hackage.haskell.org/package/nat-0.1/revision/0.cabal

% file 0.cabal 
0.cabal: ISO-8859 text

so maybe it can be patched (in Quirks) and then parser could fail on non-UTF8. But I leave that for someone else to implement.

@phadej

phadej commented Jun 9, 2023

Copy link
Copy Markdown
Collaborator Author

ping

@andreabedini

Copy link
Copy Markdown
Collaborator

Just asking: do we have a procedure to test parsing all cabal files on hackage? I am confident that the change you make here is well reasoned, but such a test would be good to have nonetheless.

@phadej

phadej commented Jun 9, 2023 •

Copy link
Copy Markdown
Collaborator Author

Just asking: do we have a procedure to test parsing all cabal files on hackage?

Yes. See hackage-tests

This change however doesn't change what accepted or not. It's just (slightly) adjusts source locations reported (the indent amount was already calculated correctly).

@andreabedini

Copy link
Copy Markdown
Collaborator

Thank you @phadej

@andreabedini andreabedini left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@ulysses4ever ulysses4ever left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM modulo commits that are already present in other PRs...

@andreabedini andreabedini added the merge me Tell Mergify Bot to merge label Jun 10, 2023
@mergify mergify Bot added the merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days label Jun 12, 2023
@ulysses4ever ulysses4ever mentioned this pull request Jun 20, 2023
4 tasks
mergify Bot added a commit that referenced this pull request Jun 22, 2023
@ffaf1

ffaf1 commented Jun 22, 2023

Copy link
Copy Markdown
Collaborator

Merged in #9051.

@ffaf1 ffaf1 closed this Jun 22, 2023
@phadej

phadej commented Jun 22, 2023

Copy link
Copy Markdown
Collaborator Author

thanks @ffaf1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days merge me Tell Mergify Bot to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants