[Haskell-cafe] Foo.Bar.hs filenames poll

erik eraker at gmail.com
Sun Dec 18 22:48:06 UTC 2016

So here's a variation which goes to the other extreme. It is completely
unsupported right now though:

╶┮▬ Bar/
 ├─┮▬ Baz/
 │ ├─╴ Internals.hs
 │ ╰─╴ hs
 ╰─┮▬ Foo/
   ├─╴ Internals.hs
   ╰─╴ hs

You may know this already (and I suspect there are those in your audience
who know as well), but this is how Python works, except that your 'hs'
files are called '__init__.py' and they're generally required for every
directory with Python modules in it (mostly you will find empty ones
littered throughout Python projects). You can, of course,  put code in the
__init__.py or rexport stuff from the modules to make them available at the
level of Bar.Baz, for instance.

For an extended example, if these were Python modules and you wrote:

"from bar.baz.internals import some_function"

The python interpreter would evaluate the top-level declarations within the
__init__.py in each directory in order (1. bar, 2.baz) before finally
importing from the internals module (at which point it would also execute
all top-level declarations there as well.
There are some clunky aspects to it and a danger of circular imports which
results in all kinds of nonsense, but one thing I like about Python-style
imports is that it's pretty much always obvious where things originated

On Dec 18, 2016 2:29 PM, "MarLinn via Haskell-Cafe" <
haskell-cafe at haskell.org> wrote:

> I suppose the real question is, as a language standard and a community
> preference, should this be considered a bug? Should people be free to use
> X.Y.hs or X/Y.hs styles?
> First off all, the support you mention seems to be incomplete, or very
> recent. At least my ghci 7.10 failed to import a module with a dot-name.
> But maybe my quick-and-dirty test was broken…
> I'll also add a fun variation to the discussion. Let's say I have two
> modules named Bar.Foo, and Bar.Baz and submodules Bar.Foo.Internals and
> Bar.Baz.Internals. (eg. for testing purposes) It always bugged me that
> the usual approach would be this:
> ╶┮▬ Bar/
>  ├─┮▬ Baz/
>  │ ╰─╴  Internals.hs
>  ├─┮▬ Foo/
>  │ ╰─╴  Internals.hs
>  ├──╴ Baz.hs
>  ╰──╴ Foo.hs
> My gripe is that here related modules are in completely unrelated
> positions. One way to solve it with dot-names would be
> ╶┮▬ Bar/ ├──╴ Baz.hs  ├──╴ Baz.Internals.hs
>  ├──╴ Foo.hs ╰──╴ Foo.Internals.hs
> But that can lead to a lot of clutter fast. So here's a variation which
> goes to the other extreme. It is completely unsupported right now though:
> ╶┮▬ Bar/
>  ├─┮▬ Baz/
>  │ ├─╴ Internals.hs
>  │ ╰─╴ hs
>  ╰─┮▬ Foo/
>    ├─╴ Internals.hs
>    ╰─╴ hs
> That hs name does look a bit ridiculous, but the idea is to have
> something like an index.html without reserving a name. If slashes and
> dots were 100% interchangeable, this would be the logical extension. Now
> related files are in related positions. Downside: The hs files don't have
> a file extension. (There could be a special case to use .hs as a special
> name instead, but that would lead to hidden files and break consistency…)
> I realize this version probably won't gain much approval, but between this
> and throwing everything and the kitchen sink on the top level just because
> some tools don't offer opened-up nested hierarchical views into directory
> structures – I would choose this one, personally. Or maybe a mixture,
> depending on actual structure. But then both options are better than the
> one with unrelated positions, and the dot-name approach might at least be
> one that works right now.
> Cheers,
> MarLinn
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20161218/ca024dba/attachment.html>

More information about the Haskell-Cafe mailing list