Quantcast

Re: Haskell-prime Digest, Vol 104, Issue 2

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Haskell-prime Digest, Vol 104, Issue 2

Soham Chowdhury

Apologies if this question's already been discussed here, but have there been any discussions about switching the meanings of the : and :: operators? The rationale here is, of course, that :: is (probably, beware of anecdata) used a lot more than : is.

Obviously this would have the effect of breaking essentially every module ever written if it were done "automatically", but could there not be something akin to what -XDataKinds did for the * kind?

I don't genuinely expect this to ever happen, and I can't exactly defend the headache this would pose for comparatively little gain (including having to check the file header if not all your code sticks to one convention), but it would still, well, be really nice. I've been doing some type-level stuff for a while using Type instead of *, and it's caused less friction than I expected there to be. As a logical extension of this, it seems like a :/:: replacement might improve ergonomics more than a little as we move towards full Dependent Haskell.

Soham


On Wed, May 17, 2017, 17:57 <[hidden email]> wrote:
Send Haskell-prime mailing list submissions to
        [hidden email]

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-prime
or, via email, send a message with subject or body 'help' to
        [hidden email]

You can reach the person managing the list at
        [hidden email]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Haskell-prime digest..."


Today's Topics:

   1. Re: Default module header `module Main where` (Matthias Fischmann)
   2. Re: Default module header `module Main where` (Iavor Diatchki)


----------------------------------------------------------------------

Message: 1
Date: Tue, 16 May 2017 21:40:49 +0200
From: Matthias Fischmann <[hidden email]>
To: Adam Bergmark <[hidden email]>
Cc: [hidden email]
Subject: Re: Default module header `module Main where`
Message-ID: <[hidden email]>
Content-Type: text/plain; charset=utf-8


you're inside the module, so you have access to all top-level
bindings, not just to the export list.

the issue with the implicit `module Main(main) where` is that it
errors if main is not defined, even though that's a perfectly harmless
situation.

(i hope i got the question right?)


On Tue, May 16, 2017 at 05:53:17PM +0000, Adam Bergmark wrote:
> Date: Tue, 16 May 2017 17:53:17 +0000
> From: Adam Bergmark <[hidden email]>
> To: José Manuel Calderón Trilla <[hidden email]>, [hidden email]
> Subject: Re: Default module header `module Main where`
>
> GHCIs current behavior seems inconsistent with this, why is foo accessible
> and why don't I get an unused warning like i do if i have an explicit
> `module Main (main) where`?
>
> ```
> $ cat Main.hs
> main :: IO ()
> main = pure ()
>
> foo :: Int
> foo = 1
>
> $ ghci Main.hs -Wall
> GHCi, version 8.0.2: http://www.haskell.org/ghc/  :? for help
> Loaded GHCi configuration from /Users/adam.bergmark/.ghci
> [1 of 1] Compiling Main             ( Main.hs, interpreted )
> Ok, modules loaded: Main.
>
> λ foo
> 1
> ```
>
> On Tue, 16 May 2017 at 19:00 José Manuel Calderón Trilla <[hidden email]>
> wrote:
>
> > Agreed, this sounds sensible.
> >
> > Can anyone think of any unintended consequences?
> >
> > -Jose
> >
> > On Tue, May 16, 2017, at 09:50 AM, Iavor Diatchki wrote:
> >
> > That seems fairly reasonable to me.
> >
> > -Iavor
> >
> > On Tue, May 16, 2017 at 7:18 AM, Joachim Breitner <
> > [hidden email]> wrote:
> >
> > Hi,
> >
> > a very small proposal to be considered for Haskell':
> >
> > Currently, the report states
> >
> >     An abbreviated form of module, consisting only of the module body,
> >     is permitted. If this is used, the header is assumed to be ‘module
> >     Main(main) where’.
> >
> > I propose to change that to
> >
> >     An abbreviated form of module, consisting only of the module body,
> >     is permitted. If this is used, the header is assumed to be ‘module
> >     Main where’.
> >
> > The rationale is that a main-less main module is still useful, e.g.
> > when you are working a lot in GHCi, and offload a few extensions to a
> > separate file. Currently, tools like hdevtools will complain about a
> > missing main function when editing such a file.
> >
> > It would also work better with GHC’s -main-is flag, and avoid problems
> > like the one described in https://ghc.haskell.org/trac/ghc/ticket/13704
> >
> >
> > I don’t see any downsides. When compiling to a binary, implementations
> > are still able to detect that a Main module is not imported by any
> > other module and only the main function is used, and optimize as if
> > only main were exported.
> >
> > Greetings,
> > Joachim
> >
> >
> >
> > --
> > Joachim “nomeata” Breitner
> >   [hidden email]https://www.joachim-breitner.de/
> >   XMPP: [hidden email] • OpenPGP-Key: 0xF0FBF51F
> >   Debian Developer: [hidden email]
> > _______________________________________________
> > Haskell-prime mailing list
> > [hidden email]
> > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-prime
> >
> > *_______________________________________________*
> > Haskell-prime mailing list
> > [hidden email]
> > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-prime
> >
> >
> > _______________________________________________
> > Haskell-prime mailing list
> > [hidden email]
> > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-prime
> >

> _______________________________________________
> Haskell-prime mailing list
> [hidden email]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-prime


--
https://zerobuzz.net/
[hidden email]
+49 179 7733 223


------------------------------

Message: 2
Date: Tue, 16 May 2017 13:25:16 -0700
From: Iavor Diatchki <[hidden email]>
To: Joachim Breitner <[hidden email]>
Cc: "[hidden email] Prime" <[hidden email]>
Subject: Re: Default module header `module Main where`
Message-ID:
        <CAGK9nupOZ4a84V+=[hidden email]>
Content-Type: text/plain; charset="utf-8"

One potential difference between the two is that the current behavior
allows the `Main` module to import `main` from another module, while the
new behavior would fail in that case.

For example, a file that has only a single line:

    import SomeOtherModule(main)

This still seems like a fairly unusual corner case (with an obvious work
around), so I don't think it matters much, but I thought I'd mention it so
that we are aware of it.






On Tue, May 16, 2017 at 7:18 AM, Joachim Breitner <[hidden email]>
wrote:

> Hi,
>
> a very small proposal to be considered for Haskell':
>
> Currently, the report states
>
>     An abbreviated form of module, consisting only of the module body,
>     is permitted. If this is used, the header is assumed to be ‘module
>     Main(main) where’.
>
> I propose to change that to
>
>     An abbreviated form of module, consisting only of the module body,
>     is permitted. If this is used, the header is assumed to be ‘module
>     Main where’.
>
> The rationale is that a main-less main module is still useful, e.g.
> when you are working a lot in GHCi, and offload a few extensions to a
> separate file. Currently, tools like hdevtools will complain about a
> missing main function when editing such a file.
>
> It would also work better with GHC’s -main-is flag, and avoid problems
> like the one described in https://ghc.haskell.org/trac/ghc/ticket/13704
>
>
> I don’t see any downsides. When compiling to a binary, implementations
> are still able to detect that a Main module is not imported by any
> other module and only the main function is used, and optimize as if
> only main were exported.
>
> Greetings,
> Joachim
>
>
>
> --
> Joachim “nomeata” Breitner
>   [hidden email]https://www.joachim-breitner.de/
>   XMPP: [hidden email] • OpenPGP-Key: 0xF0FBF51F
>   Debian Developer: [hidden email]
> _______________________________________________
> Haskell-prime mailing list
> [hidden email]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-prime
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-prime/attachments/20170516/0c22e88d/attachment-0001.html>

------------------------------

Subject: Digest Footer

_______________________________________________
Haskell-prime mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-prime


------------------------------

End of Haskell-prime Digest, Vol 104, Issue 2
*********************************************

_______________________________________________
Haskell-prime mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-prime
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Switching the meanings of the : and :: (was Haskell-prime Digest, Vol 104, Issue 2)

Erik de Castro Lopo-34
Soham Chowdhury wrote:

> Apologies if this question's already been discussed here, but have there
> been any discussions about switching the meanings of the : and ::
> operators? The rationale here is, of course, that :: is (probably, beware
> of anecdata) used a lot more than : is.
>
> Obviously this would have the effect of breaking essentially every module
> ever written if it were done "automatically", but could there not be
> something akin to what -XDataKinds did for the * kind?

Sorry, from a cost/benefit analysis point of view this doesn't look
very promising at all.

The costs are very obvious:

* Implementation in GHC and ongoing maintenance.
* The extra cognitive load put on every developer who has to work on
  code that has both forms.

There are probably others, but as far as I am concerned the second
alone far outweights any potential benefit.

Erik
--
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/
_______________________________________________
Haskell-prime mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-prime
Loading...