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

virtual-modules section: docs #7602

Closed
ciez opened this issue Aug 31, 2021 · 8 comments
Closed

virtual-modules section: docs #7602

ciez opened this issue Aug 31, 2021 · 8 comments

Comments

@ciez
Copy link

ciez commented Aug 31, 2021

Could anyone hint / share links to a description of .cabal file virtual-modules section?

The docs show but a placeholder:
https://cabal.readthedocs.io/en/3.4/cabal-package.html?highlight=virtual-modules#pkg-field-virtual-modules

@Mikolaj
Copy link
Member

Mikolaj commented Aug 31, 2021

That's just a flat list of modules, just as exposed-modules.

Some snippets from git grep -30 virtual-modules:

Cabal/ChangeLog.md: * Added virtual-modules field, to allow modules that are not built
Cabal/ChangeLog.md- but registered (#4875).

doc/cabal-package.rst:.. pkg-field:: virtual-modules: identifier list
doc/cabal-package.rst- :since: 2.2
doc/cabal-package.rst-
doc/cabal-package.rst- A list of virtual modules provided by this package. Virtual modules
doc/cabal-package.rst- are modules without a source file. See for example the GHC.Prim
doc/cabal-package.rst- module from the ghc-prim package. Modules listed here will not be
doc/cabal-package.rst- built, but still end up in the list of exposed-modules in the
doc/cabal-package.rst- installed package info when the package is registered in the package
doc/cabal-package.rst- database.

@phadej
Copy link
Collaborator

phadej commented Aug 31, 2021

TL;DR you don't need virtual-modules (except if you are GHC developer). It's a feature solely for GHC need: GHC.Prim module in ghc-prim doesn't really exist as a source. GHC just knows it.

@ciez
Copy link
Author

ciez commented Aug 31, 2021

Cheers Mikolaj, Oleg.

So for all practical purposes could this file be added in ghc-prim/GHC folder to the same effect:
Prim.hs
?

Background:

GHC.Prim is imported in a few places. A custom (editor) name resolver does not find GHC.Prim when viewing / editing GHC sources.

@phadej
Copy link
Collaborator

phadej commented Aug 31, 2021

@ciez no. That would be a different module. It also may confuse build system, if source existed. GHC.Prim contains the primops, which are hard-wired into compiler. I think things (like costom name resolver) just have to know about that corner case, i.e. that virtual-modules (which is only one) doesn't exist. E.g. the module finder in GHC itself has following code:

   -- special case for GHC.Prim; we won't find it in the filesystem.
   -- This is important only when compiling the base package (where GHC.Prim
   -- is a home module).
   if mod `installedModuleEq` gHC_PRIM
         then return (InstalledFound (error "GHC.Prim ModLocation") mod)
         else searchPathExts home_path mod exts

@ciez
Copy link
Author

ciez commented Aug 31, 2021

So in this particular case, what Haskell (apart from C, C++) symbols does GHC.Prim export?

All the symbols exported by
GHC.CString,
GHC.Classes,
GHC.Debug,
GHC.IntWord64,
GHC.Magic,
GHC.Prim.Ext,
GHC.Tuple,
GHC.Types
or ..?

@phadej
Copy link
Collaborator

phadej commented Aug 31, 2021

The haddocks are correct. (EDIT: They are magically generated, that's why they don't exist for ghc-prim-0.7 on hackage). The primitive types like Int# and operations on them like (+#)

@phadej
Copy link
Collaborator

phadej commented Aug 31, 2021

I found this: https://downloads.haskell.org/ghc/9.2.1-rc1/docs/html/libraries/ghc-prim-0.8.0/src/GHC.Prim.html

@ciez
Copy link
Author

ciez commented Aug 31, 2021

Cheers Oleg!
This is just what I was looking for.

Appreciate this.

@ciez ciez closed this as completed Aug 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants