PROPOSAL: Literate haskell and module file names

Greg Weber greg at gregweber.info
Sun Mar 16 16:23:33 UTC 2014


Can we get a little more information on what pandoc is doing? Is there a
documentation link?
In part am wondering if it is possible to have a Foo.hs.md file that pandoc
compiles down to Foo.hs with or without help from GHC.


On Sun, Mar 16, 2014 at 5:56 AM, Merijn Verstraaten
<merijn at inconsistent.nl>wrote:

> Ola!
>
> I didn't know what the most appropriate venue for this proposal was so I
> crossposted to haskell-prime and glasgow-haskell-users, if this isn't the
> right venue I welcome advice where to take this proposal.
>
> Currently the report does not specify the mapping between filenames and
> module names (this is an issue in itself, it essentially makes writing
> haskell code that's interoperable between compilers impossible, as you
> can't know what directory layout each compiler expects). I believe that a
> minimal specification *should* go into the report (hence, haskell-prime).
> However, this is a separate issue from this proposal, so please start a new
> thread rather than sidetracking this one :)
>
> The report only mentions that "by convention" .hs extensions imply normal
> haskell and .lhs literate haskell (Section 10.4). In the absence of
> guidance from the report GHC's convention of mapping module Foo.Bar.Baz to
> Foo/Bar/Baz.hs or Foo/Bar/Baz.lhs seems the only sort of standard that
> exists. In general this standard is nice enough, but the mapping of
> literate haskell is a bit inconvenient, it leaves it completelyl ambiguous
> what the non-haskell content of said file is, which is annoying for tool
> authors.
>
> Pandoc has adopted the policy of checking for further file extensions for
> literate haskell source, e.g. Foo.rst.lhs and Foo.md.lhs. Here .rst.lhs
> gets interpreted as being reStructured Text with literate haskell and
> .md.lhs is Markdown with literate haskell. Unfortunately GHC currently maps
> filenames like this to the module names Foo.rst and Foo.md, breaking
> anything that wants to import the module Foo.
>
> I would like to propose allowing an optional extra extension in the pandoc
> style for literate haskell files, mapping Foo.rst.lhs to module name Foo.
> This is a backwards compatible change as there is no way for Foo.rst.lhs to
> be a valid module in the current GHC convention. Foo.rst.lhs would map to
> module name "Foo.rst" but module name "Foo.rst" maps to filename
> "Foo/rst.hs" which is not a valid haskell module anyway as the rst is
> lowercase and module names have to start with an uppercase letter.
>
> Pros:
>  - Tool authors can more easily determine non-haskell content of literate
> haskell files
>  - Currently valid module names will not break
>  - Report doesn't specify behaviour, so GHC can do whatever it likes
>
> Cons:
>  - Someone has to implement it
>  - ??
>
> Discussion: 4 weeks
>
> Cheers,
> Merijn
>
>
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20140316/0ef45d9f/attachment.html>


More information about the Glasgow-haskell-users mailing list