[m-users.] Creating an interface module

Volker Wysk post at volker-wysk.de
Fri Jul 14 18:14:07 AEST 2023


Am Freitag, dem 14.07.2023 um 09:04 +0100 schrieb Sean Charles
(emacstheviking):
> What about 
> 
> :- publish_module foo.
> 
> or
> 
> :- export_module foo.
> 
> 
> This imports all the interface things from foo and literally re-exports them as though they were declared inline?

I'd call it ":- reexport_module ...". The difference is that in your
suggestion, the reexported things become part of the reexporting module,
whereas in my suggestion, they stay part of the reexported module. 

I'm not sure what is preferable, but I guess that my suggestion would be
easier to implement. But then you have to cope with it not being obvious to
which module somethings belongs...

Volker

> 
> 
> 
> > On 14 Jul 2023, at 09:02, Volker Wysk <post at volker-wysk.de> wrote:
> > 
> > Am Freitag, dem 14.07.2023 um 17:41 +1000 schrieb Peter Wang:
> > > On Tue, 11 Jul 2023 16:59:42 +0200 Volker Wysk <post at volker-wysk.de> wrote:
> > > > Hi
> > > > 
> > > > In Haskell, you can import things into a first module from a second module
> > > > and reexport them from the first one. So you can use the first module as an
> > > > interface to things from several modules.
> > > > 
> > > > This doesn't seem to be possible in Mercury. You need to import all the
> > > > modules which contain parts of what you need. 
> > > > 
> > > > Submodules don't seem to be the answer.
> > > > 
> > > > Am I missing something? What is the recommended practice when you want to
> > > > split a library into several modules?
> > > 
> > > Mercury's module system is pretty basic and doesn't support
> > > re-exporting.
> > 
> > I can think of a solution that looks easy to implement. In a module there
> > could be some statement ":- import_as_well(...)", which tells the compiler
> > to import some other modules as well, when the module with the statement is 
> > being imported.
> > 
> > Cheers,
> > Volker
> > _______________________________________________
> > users mailing list
> > users at lists.mercurylang.org
> > https://lists.mercurylang.org/listinfo/users
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.mercurylang.org/archives/users/attachments/20230714/9729c66a/attachment.sig>


More information about the users mailing list