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

Discover more modules (exes, sub-libraries, test-suites) #16

Merged
merged 10 commits into from
Sep 5, 2023

Conversation

ramirez7
Copy link
Collaborator

@ramirez7 ramirez7 commented Aug 29, 2023

exe Main modules are prefixed with the exe name, fixing this old graphmod bug: yav/graphmod#28

Fixes #8

exe Main modules are prefixed with the exe name, fixing this
old graphmod bug: yav/graphmod#28
otherMod <- "Main" : buildInfo.otherModules
pure Module
{ name = fromString $
if otherMod == "Main"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is kind of a dumb way to do this, but it works.

@@ -20,3 +20,7 @@ test: graphex.cabal
fmt:
fd .hs --exec stylish-haskell -i
.PHONY: fmt

graph.json:
cabal run -v0 exe:graphex -- cabal > graph.json
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We need -v0 due to haskell/cabal#7790

@ramirez7
Copy link
Collaborator Author

I want to make discovery command-line configurable + allow the user to optionally also discover external modules as well.

@ramirez7
Copy link
Collaborator Author

ramirez7 commented Sep 5, 2023

$ graphex cabal --help
Usage: graphex cabal [--discover-exes] [--discover-tests] [--include-external]

  Cabal operations

Available options:
  --discover-exes          Discover exe import dependencies
  --discover-tests         Discover test import dependencies
  --include-external       Include external import dependencies
  -h,--help                Show this help text

The only thing left is to add to the existing graphex cabal test suite to test the new stuff. I tested with the CLI by hand on graphex itself and it seemed correct.

@ramirez7 ramirez7 requested a review from dustin September 5, 2023 01:47
fs <- getDirectoryContents "." -- XXX
mods <- fmap fold . traverse discoverCabalModules . filter ((".cabal" ==) . takeExtension) $ fs
mods <- fmap fold . traverse (discoverCabalModules opts) . filter ((".cabal" ==) . takeExtension) $ fs
Copy link
Owner

Choose a reason for hiding this comment

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

I keep feeling like fmap fold . traverse should be a thing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's foldMapA? But it's one pass:

foldMapA
  :: forall t f a b
   . Foldable t
  => Applicative f
  => Monoid b
  => (a -> f b)
  -> t a
  -> f b
foldMapA f = getAp . foldMap (Ap . f)

Hm I should probably write a proposal to add it to base. I always write it in new projects 😆

@ramirez7 ramirez7 merged commit d330549 into dustin:main Sep 5, 2023
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.

graphex cabal: test & exe dependencies too
2 participants