Skip to content

DRAFT: Cabal project plugin #4615

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rm41339
Copy link
Contributor

@rm41339 rm41339 commented Jun 6, 2025

Draft of cabal.project plugin for GSoC 2025

Still in progress!

@rm41339 rm41339 requested review from fendor and michaelpj as code owners June 6, 2025 21:43
@fendor fendor marked this pull request as draft June 9, 2025 12:15
@rm41339 rm41339 force-pushed the cabal-project-plugin branch from cc35958 to 5876ac7 Compare July 28, 2025 13:15
Comment on lines +68 to +70
, pluginHandlers =
mconcat
[]
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can just omit pluginHandlers instead here, if you don't implement any.


cabalProjectRules :: Recorder (WithPriority Log) -> PluginId -> Rules ()
cabalProjectRules recorder plId = do
-- Make sure we initialise the cabal project files-of-interest.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a nitpick, but you sometimes write cabal project and sometimes, cabal.project.
I would prefer if we were consistent here.

log' = logWith recorder

{- | This is the kick function for the cabal project plugin.
We run this action, whenever we shake session us run/restarted, which triggers
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
We run this action, whenever we shake session us run/restarted, which triggers
We run this action, whenever a shake session is run/restarted, which triggers

Diagnostics.fatalParseErrorDiagnostic file
("Failed to parse cabal.project file: " <> T.pack (show perr))

(_warnings, Right fields) ->
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should not just ignore the warnings, the user will be interested to see them as they are also part of diagnostics.

let perr = NE.head errs
in Left $
Diagnostics.fatalParseErrorDiagnostic file
("Failed to parse cabal.project file: " <> T.pack (show perr))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this a nicely readable view for the user?
Also, you are only showing the first error in the list, we also want to know about the other ones.

main = do
defaultTestRunner $
testGroup
"Cabal Plugin Tests"
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should refer to cabal.project files.

let cabalFp = root </> "cabal.project"
bytes <- BS.readFile cabalFp
result <- E.try @E.IOException (Lib.parseCabalProjectFileContents cabalFp bytes)
:: IO ( Either
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this type signature necessary?

Comment on lines +34 to +36
-- | these functions are used to detect cabal kicks
-- and look at diagnostics for cabal files
-- kicks are run everytime there is a shake session run/restart
Copy link
Collaborator

Choose a reason for hiding this comment

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

docs talks about cabal files instead of cabal.project

Comment on lines +46 to +48
-- | list comparison where the order in the list is irrelevant
(@?==) :: (HasCallStack, Ord a, Show a) => [a] -> [a] -> Assertion
(@?==) l1 l2 = sort l1 @?= sort l2
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems unused.

Comment on lines +1 to +3
#include <iostream>
int main() { std::cout << "OK
"; return 0; }
Copy link
Collaborator

Choose a reason for hiding this comment

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

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.

4 participants