You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now that cabal has common stanzas, the only thing keeping me using hpack is that hpack will, by default, autodiscover all of your modules and stuff them into exposed-modules (you can disable this by explicitly defining that stanza). This feature is really convenient to me.
Mimicing that behavior seems like it might be against the Cabal philosophy, as it's implicit -- "If exposed-modules is not defined, collect all modules not listed in other-modules and make them exposed-modules."
A middle ground solution that provides convenience with a degree of explicitness is glob patterns for the module listings. Consider this syntax:
exposed-modules: *
This would find all modules in the source directory and add them as exposed-modules. Kinda like hpack's autodiscovery, but we're explicitly writing "please find all the modules for me."
You could also write:
exposed-modules:
Control.Monad.*
which would only collect modules under the Control.Monad namespace into exposed-modules -- any other modules would need to be either explicitly added to exposed-modules or other-modules.
Reacted by Will Fancher, BorisNikulin, Troels Henriksen, Jonathan Knowles, Shinya Yamaguchi, John Ky, Jakub Zarybnicky, Alexey Raga, Dennis Gosnell, Domen Kožar and 54 more
Reacted by Herbert Valerio Riedel and Merijn Verstraaten
It'd be also convenient to be able to specify module names to be treated as exceptions from auto-exposing with glob patterns: other-modules: Control.Monad.Internal.*.
Reacted by Matt Parsons, BorisNikulin, Alexey Raga, Liam McDermott, ivxvm, funketh and Gergő Érdi
Right. I'd think we'd want some logic relating the two. Explicit always takes precedence over glob. So other-modules explicit takes precedence over glob in exposed-modules, and exposed-modules explicit takes precedence over glob in other-modules. If both are globs or both are explicit, I'd suggest an error, rather than trying to be too clever and pick a potentially nonobvious direction to resolve the ambiguity?
I also don't know if there are interaction effects with backpack that we'd have to worry about -- i.e is it genuinely always the case that given a glob we can simply scan a file-listing without inspecting any contents to determine what it expands to?
I have no idea how this would interact with Backpack 🤔
Reacted by BorisNikulin, fendor, Jakub Zarybnicky, Alexey Raga, Dennis Gosnell, Dmitrii Kovanikov, Veronika Romashkina, Junyoung/"Clare" Jang, André Szabolcs Szelp, Liam McDermott and 3 more
I’d be 100% against allowing files with globs to be uploded to Hackage, as ”which package exposes XYZ module” will be impossible to answer only considering the index.
I’d like to have solution to this, but losing the declarativeness is huge concern, and if it’s not addressed, this will be **wontdo**.
On 5 Aug 2019, at 14.21, Domen Kožar ***@***.***> wrote:
I'd be happy to chip in to get this one done. It's the last annoyance I have that had hpack fixed :)
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
You kind of lose git repository to hackage mapping, but that was never the thing with revisions anyway.
Yep, revisions are already a wart (knowing that they are a sad necessary fix), break freeze files if you don't freeze the index, cause problems for distributions, are infrastructure specific, ...
Let's not take this as an argument of good design to allow more semi-defined behavior.
I feel like hpack is exactly what fills the gap here and careful maintainers commit both the hpack and the .cabal files to their repository. Is this really cabals job? If not hpack, then it sounds more like an IDE feature.
i.e. in the case when new modules are added, I run cabal-fmt --inplace my.cabal and exposed-modules are re-populated.
The functionality is bare-bones, let's see what will be needed. In one project, I simply moved non exposed-modules into other hs-source-dirs (actually other-modules, and main-is: Main.hs is in other dir now).
Reacted by Domen Kožar, Herbert Valerio Riedel, Mohammad Hasani, Artem Pelenitsyn and malteneuss
cabal-fmt looks helpful and useful. However, the UX of calling command to discover modules is not the same as automatic support of modules discovery by the build tool. In that case, I might as well write the module name manually.
hpack showed the benefits of such package configuration features like metadata deduplication and automatic module discovery. And if you can reduce duplication of stanza information within a single package using common stanzas, a lot of people are still using hpack because they found the automatic module discovery feature handy. For me, the drawbacks of using hpack outweigh the benefits of its features, and I'm not using it in my projects. However, this particular feature of the module listing discovery is very useful. It makes Haskell development experience smoother, more pleasant and more beginner-friendly, which is very important for Haskell.
As a maintainer of multiple open-source Haskell libraries and applications, I welcome every contribution. And I want various people to be able to contribute to my projects with as little hassle as possible. That's why I support both build tools cabal and stack. And I find the number of configuration files required for a single Haskell repository too big to my taste:
and there could be more, the list is not exhaustive
I think that reducing the number of configuration files required for a project, and the number of tools and formats people need to know to develop Haskell projects while preserving the same features is a goal worth trying to achieve. It seems to me that this particular minor (in terms of implementation) feature of module listing discovery can push cabal much further and helps already fractured community to become closer to the consensus of package development.
Reacted by Dennis Gosnell, André Szabolcs Szelp, Cody Goodman, funketh, kafji, David Simmons-Duffin and Jakub Nowak
It seems to me that this particular minor (in terms of implementation) feature of module listing discovery can push ...
I'll be happy to see a PR.
My experience on Cabal and cabal-install (and downstream tooling using Cabal as a library) says very opposite. This change is not minor, as .cabal file interpretation becomes file-system state / tarball dependent. (The extra-source-files is different, at least for now, as those are only interesting for sdist command).
EDIT: note the fact that hpack "works" is because there is clear stage separation. package.yaml is compiled to pkgname.cabal, and pkgname.cabal is used as input to actual build tooling. Blurring the boundary, requiring to .cabal files to be interpreted before further consumption it tricky.
Reacted by Herbert Valerio Riedel, Merijn Verstraaten and Javier Neira
So it seems like the design where globs are permitted in exposed-modules and expanded during cabal sdist is promising and solves all of the problems we are aware of but is blocked on exact printing for cabal files? Is that an accurate summary of where this issue is?
I’d still really really like to see this happen; in my mind the evidence that people generally just don’t want to explicitly list out every module in their project is extremely strong:
the existence of various tools like hpack (including the stack integration), autopack, and cabal-auto-expose (which seems to be the same idea as autopack)
the 👍/👎ratio on this issue
the fact that few other languages/build systems require you to do this
Reacted by Dennis Gosnell, Artem Pelenitsyn, Liam McDermott, funketh, Maxime DIDIER, Martin Šošić, theGhostJW, David Garland and eldritch-cookie
Reacted by Martin Šošić, Liam McDermott, George Thomas and David Garland
Please do bug them. :) There's quite a bit of design discussion in the github project about it (or scattered among the tickets listed there), so it should be ready to actually implement.
It would be awesome to see this implemented -> in a bigger projects, when moving modules around and refactoring, updating exposed-modules becomes so much of a pain that it deters me a bit from even doing changes in the code. I will be looking at autopack now, but it would be great if cabal supported this natively -> it is weird having to explain to junior devs why they need to do this in cabal when in popular languages this is not needed.
@Mikolaj design discussion that is scattered -> how hard would be to gather that in one spot, to make it easier for somebody to contribute?
@Mikolaj design discussion that is scattered -> how hard would be to gather that in one spot, to make it easier for somebody to contribute?
That, and making a summary of what similar components are ready and what needs to be done, would likely be a major part of the work needed for the whole task, including coding.
So it seems like the design where globs are permitted in exposed-modules and expanded during cabal sdist is promising and solves all of the problems we are aware of but is blocked on exact printing for cabal files?
I'm interested as to whether this is the only thing we'd accept or whether we would also be okay with Domen's suggestion:
What if glob would be allowed for local development but rejected by hackage.
Hackage already has higher standards than cabal for what cabal files it will accept. It would be quite reasonable for it to reject module wildcards. It also cleaves the userbase at a natural fault line:
People who publish libraries on Hackage will need to have explicit module listings, probably also during development, like today
People who work on large industrial applications that are not published on Hackage will never need to have explicit module listings.
I guess the objection would be that this (probably?) requires support for module wildcards in Cabal-the-library and not just cabal-install? On the other hand, it doesn't rely on exact-printing, which is perpetually just out of reach...
Reacted by matil019, Dennis Gosnell, John Ericson and Martin Šošić
Reacted by Martin Šošić, Dennis Gosnell and Lua Viana Reis
I think it would be good to put in Cabal the library for a different reason, which is an alternative implementation.
Instead of doing the globing ourselves, we could have GHC simply tell Cabal about all the modules it found. (We can get this from ghc -M today, even).
Nevermind backpack, there are things like Happy / Alex too where we end up getting autogenerated modules. Globbing would have to reproduce all that logic, but GHC knows what libraries is is going to build.
I would also like a version where we can say if different source directories for exposed or hidden modules. This works with either the we-glob or GHC-tells-us approach (since we can see where the modules are located). I think it's good practice to put different sorts of things in different directories anyways, and this sidesteps the question of exactly what sorts of globs we want, and what the priority order between different glob stanzas would be, since directories are trivially disjoint (and nesting source dirs should already be an error, right?).
First: we want less entanglement between GHC and Cabal.
Yes, but is entirely a matter of opinion whether this is more or less entanglement. The installed .conf file already contains information which is computed with GHC's aid, after all.
Second: I doubt that even works properly with cabal conditionals around hs-source-dirs and the like.
Hmm? If you have conditional source dirs, then you get conditional which modules are provided. That is true with globs too.
Activity
23Skidoo commentedon May 24, 2018
It'd be also convenient to be able to specify module names to be treated as exceptions from auto-exposing with glob patterns:
other-modules: Control.Monad.Internal.*.gbaz commentedon May 24, 2018
Right. I'd think we'd want some logic relating the two. Explicit always takes precedence over glob. So other-modules explicit takes precedence over glob in exposed-modules, and exposed-modules explicit takes precedence over glob in other-modules. If both are globs or both are explicit, I'd suggest an error, rather than trying to be too clever and pick a potentially nonobvious direction to resolve the ambiguity?
gbaz commentedon May 24, 2018
I also don't know if there are interaction effects with backpack that we'd have to worry about -- i.e is it genuinely always the case that given a glob we can simply scan a file-listing without inspecting any contents to determine what it expands to?
parsonsmatt commentedon May 24, 2018
Yeah, given the following modules:
I'd expect the following:
and a warning/error that
module Bazis not in either listing, as happens nowBecause the explicit
other-modulesoverrides the*globbing.For the same reason as above.
I have no idea how this would interact with Backpack 🤔
cdepillabout commentedon May 2, 2019
It would be really nice to get this change into cabal.
This is the sole reason we are still using
hpackat work.domenkozar commentedon Aug 5, 2019
I'd be happy to chip in to get this one done. It's the last annoyance I have that hpack fixed :)
phadej commentedon Aug 5, 2019
domenkozar commentedon Aug 5, 2019
What if glob would be allowed for local development but rejected by hackage. For hackage
sdistcould substitute glob with the actual files.You kind of lose git repository to hackage mapping, but that was never the thing with revisions anyway.
hasufell commentedon Aug 6, 2019
Yep, revisions are already a wart (knowing that they are a sad necessary fix), break freeze files if you don't freeze the index, cause problems for distributions, are infrastructure specific, ...
Let's not take this as an argument of good design to allow more semi-defined behavior.
I feel like hpack is exactly what fills the gap here and careful maintainers commit both the hpack and the .cabal files to their repository. Is this really cabals job? If not hpack, then it sounds more like an IDE feature.
phadej commentedon Aug 10, 2019
FWIW, I released https://hackage.haskell.org/package/cabal-fmt-0.1 which in addition to (opinionatedly) formatting your
.cabalfile can expandexposed-modules, e.g.i.e. in the case when new modules are added, I run
cabal-fmt --inplace my.cabalandexposed-modulesare re-populated.The functionality is bare-bones, let's see what will be needed. In one project, I simply moved non
exposed-modulesinto otherhs-source-dirs(actuallyother-modules, andmain-is: Main.hsis in other dir now).chshersh commentedon Aug 15, 2019
cabal-fmtlooks helpful and useful. However, the UX of calling command to discover modules is not the same as automatic support of modules discovery by the build tool. In that case, I might as well write the module name manually.hpackshowed the benefits of such package configuration features like metadata deduplication and automatic module discovery. And if you can reduce duplication of stanza information within a single package using common stanzas, a lot of people are still usinghpackbecause they found the automatic module discovery feature handy. For me, the drawbacks of usinghpackoutweigh the benefits of its features, and I'm not using it in my projects. However, this particular feature of the module listing discovery is very useful. It makes Haskell development experience smoother, more pleasant and more beginner-friendly, which is very important for Haskell.As a maintainer of multiple open-source Haskell libraries and applications, I welcome every contribution. And I want various people to be able to contribute to my projects with as little hassle as possible. That's why I support both build tools
cabalandstack. And I find the number of configuration files required for a single Haskell repository too big to my taste:I think that reducing the number of configuration files required for a project, and the number of tools and formats people need to know to develop Haskell projects while preserving the same features is a goal worth trying to achieve. It seems to me that this particular minor (in terms of implementation) feature of module listing discovery can push
cabalmuch further and helps already fractured community to become closer to the consensus of package development.phadej commentedon Aug 15, 2019
I'll be happy to see a PR.
My experience on
Cabalandcabal-install(and downstream tooling usingCabalas a library) says very opposite. This change is not minor, as.cabalfile interpretation becomes file-system state / tarball dependent. (Theextra-source-filesis different, at least for now, as those are only interesting forsdistcommand).EDIT: note the fact that
hpack"works" is because there is clear stage separation.package.yamlis compiled topkgname.cabal, andpkgname.cabalis used as input to actual build tooling. Blurring the boundary, requiring to.cabalfiles to be interpreted before further consumption it tricky.23 remaining items
philderbeast commentedon Mar 31, 2022
@hasufell that is how hpack-dhall works.
hdgarrood commentedon Nov 16, 2022
So it seems like the design where globs are permitted in exposed-modules and expanded during
cabal sdistis promising and solves all of the problems we are aware of but is blocked on exact printing for cabal files? Is that an accurate summary of where this issue is?I’d still really really like to see this happen; in my mind the evidence that people generally just don’t want to explicitly list out every module in their project is extremely strong:
gbaz commentedon Nov 17, 2022
@hdgarrood is this you volunteering to work on exactprint? :-)
hdgarrood commentedon Nov 17, 2022
Probably not, sorry! I think the best I can do is bug some of my colleagues about it :(
Mikolaj commentedon Dec 15, 2022
Please do bug them. :) There's quite a bit of design discussion in the github project about it (or scattered among the tickets listed there), so it should be ready to actually implement.
Martinsos commentedon Mar 9, 2023
It would be awesome to see this implemented -> in a bigger projects, when moving modules around and refactoring, updating exposed-modules becomes so much of a pain that it deters me a bit from even doing changes in the code. I will be looking at autopack now, but it would be great if cabal supported this natively -> it is weird having to explain to junior devs why they need to do this in cabal when in popular languages this is not needed.
@Mikolaj design discussion that is scattered -> how hard would be to gather that in one spot, to make it easier for somebody to contribute?
Mikolaj commentedon Mar 9, 2023
That, and making a summary of what similar components are ready and what needs to be done, would likely be a major part of the work needed for the whole task, including coding.
domenkozar commentedon Feb 19, 2024
https://github.com/tfausak/cabal-gild
michaelpj commentedon Jun 8, 2024
I'm interested as to whether this is the only thing we'd accept or whether we would also be okay with Domen's suggestion:
Hackage already has higher standards than cabal for what cabal files it will accept. It would be quite reasonable for it to reject module wildcards. It also cleaves the userbase at a natural fault line:
I guess the objection would be that this (probably?) requires support for module wildcards in Cabal-the-library and not just cabal-install? On the other hand, it doesn't rely on exact-printing, which is perpetually just out of reach...
Ericson2314 commentedon Nov 29, 2024
I think it would be good to put in
Cabalthe library for a different reason, which is an alternative implementation.Instead of doing the globing ourselves, we could have GHC simply tell Cabal about all the modules it found. (We can get this from
ghc -Mtoday, even).Nevermind backpack, there are things like Happy / Alex too where we end up getting autogenerated modules. Globbing would have to reproduce all that logic, but GHC knows what libraries is is going to build.
I would also like a version where we can say if different source directories for exposed or hidden modules. This works with either the we-glob or GHC-tells-us approach (since we can see where the modules are located). I think it's good practice to put different sorts of things in different directories anyways, and this sidesteps the question of exactly what sorts of globs we want, and what the priority order between different glob stanzas would be, since directories are trivially disjoint (and nesting source dirs should already be an error, right?).
hasufell commentedon Nov 30, 2024
I don't think this is a good suggestion.
First: we want less entanglement between GHC and Cabal.
Second: I doubt that even works properly with cabal conditionals around
hs-source-dirsand the like.Ericson2314 commentedon Nov 30, 2024
Yes, but is entirely a matter of opinion whether this is more or less entanglement. The installed
.conffile already contains information which is computed with GHC's aid, after all.Hmm? If you have conditional source dirs, then you get conditional which modules are provided. That is true with globs too.
devnchill commentedon Mar 11, 2026
guys and update ?