[ghc-steering-committee] GHC2021: a final plea for ScopedTypeVariables

Simon Marlow marlowsd at gmail.com
Wed Dec 9 14:52:46 UTC 2020


On Wed, 9 Dec 2020 at 13:40, Joachim Breitner <mail at joachim-breitner.de>
wrote:

> Hi,
>
> Am Mittwoch, den 09.12.2020, 12:08 +0000 schrieb Simon Peyton Jones via
> ghc-steering-committee:
> > I agree with this.  Not having scoped type variables (in any form) is
> > a huge blemish.  The existing design may not be perfect, but it’s
> > worked rather well for a long time.
>
> The same is true for ViewPatterns, which are even more harmless (clear
> syntactic opt-in; no spooky effect at a distance when type signature
> and definition are far apart).
>
> There we argued that the fact that we don’t think it’s perfect, and
> some wiki page with an alternative design exists, was enough to plea
> against it.
>
> Here, the situation seems equivalent (we know of better designs, namely
> binding type variables on the LHS of the equation).
>
> Can we justify why we go one way here and another way there? Is it
> because ViewPatterns are just mere convenience, and ScopedTypeVariables
> are absolutely needed for some things?
>

Yes to your last point here. But other points to note about ViewPatterns:

Technically ViewPatterns are not just a convenience, at least when combined
with PatternSynonyms. The only way that you can write a PatternSynonym that
does some arbitrary computation in the pattern is to use ViewPatterns -
*this* is the killer feature of PatternSynonyms, because it provides full
power to abstract over constructor names. You can define a constructor that
expands to some arbitrary computation in the pattern. Here's an example:
https://stackoverflow.com/questions/43838550/using-viewpatterns-and-patternsynonyms-to-simply-pattern-matches

(The alternative ViewPatterns design would also provide this functionality,
incidentally.)

But anyway, this is not an argument to accept ViewPatterns, because it
doesn't look like PatternSynonyms will be in GHC2021 (shame!).

Outside of the PatternSynonyms use-case, I don't think ViewPatterns are all
that widely used. We have figures of 7% proliferation and 20% popularity,
but that doesn't tell us (1) how much the extension is really used, and (2)
how often it is used because it's the only way to do certain things with
PatternSynonyms. Some more data would be nice. I base my intuition here on
the fact that I hardly ever encounter any ViewPatterns, but I could well be
living in a bubble of some kind.

If the extension really isn't very widely-used, and we think the design
might change, we can limit the churn in the future by avoiding having the
extension on by default.

Cheers
Simon




>
> Cheers,
> Joachim
>
>
>
> --
> Joachim Breitner
>   mail at joachim-breitner.de
>   http://www.joachim-breitner.de/
>
>
> _______________________________________________
> ghc-steering-committee mailing list
> ghc-steering-committee at haskell.org
> https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-steering-committee/attachments/20201209/a53ab0fa/attachment.html>


More information about the ghc-steering-committee mailing list