Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module Name Plugin: Treat modules starting with lowercase as Main module #616

Merged
merged 1 commit into from
Dec 2, 2020
Merged

Module Name Plugin: Treat modules starting with lowercase as Main module #616

merged 1 commit into from
Dec 2, 2020

Conversation

konn
Copy link
Collaborator

@konn konn commented Nov 23, 2020

Currently, module name plugin treats basename of file as module name.
This inferes, for example, the module name of app/exe01.hs as exe01, contrary to the expectation that they must be Main.

This pull-requests addresses this issue by defaulting to Main when the file name is starting with non-upper cases.

Perhaps, the logic itself can be refined so that it infers it Main only when the lowercased file is located right after the source-dirs?

@konn konn changed the title modulename-main-like Module Name Plugin: Treat modules starting with lowercase as Main module Nov 23, 2020
@jneira
Copy link
Member

jneira commented Nov 23, 2020

@konn thanks for the improvement. Is a main module the unique case where a module can start with lower case?

@tittoassini please, could you take a look?

@konn
Copy link
Collaborator Author

konn commented Nov 23, 2020

Is a main module the unique case where a module can start with lower case?

Well, strictly speaking, it could be different if it is specified with ghc option like -main-is NonStandardMain; without such options, modules starting with a lowercase must be treated as Main, IIRC.

At least, module names starting with a lowercase are rejected hence we should either provide a common default name for them or just stopping suggesting module names for them.

@jneira
Copy link
Member

jneira commented Nov 23, 2020

just stopping suggesting module names for them

The module header is optional for them, right? So it could be an alternative. However this pr is a improvement over the actual situation so imo it could be merged and only switch to a more defensive option if there is concrete real issues about.

Copy link
Member

@jneira jneira left a comment

Choose a reason for hiding this comment

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

LGTM, will merge soon if @tittoassini cant take a final look

@tittoassini
Copy link
Contributor

Sorry for the delay in answering, the change seems perfectly legit to me.

(Un)related question:

Most of the changes in the commit are 'noise' due to differences in the formatting of the import statements.

Is there a project-wide standard for formatting?

@jneira
Copy link
Member

jneira commented Dec 2, 2020

@tittoassini

Is there a project-wide standard for formatting?

I am afraid it is not.

It is a somewhat tricky question, as afaik almost each dev has a favourite formatting flavour 😝
In general we suggest to not make those changes and respect the formatting of each file in the hope some day someone will do the titanic effort to apply a formatter to all codebase, to start following it.

But personally i am not very strict about, as this pr demonstrates 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants