[Haskell-cafe] New type of ($) operator in GHC 8.0 is problematic

Tom Ellis tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Sun Feb 7 15:45:37 UTC 2016


On Sun, Feb 07, 2016 at 10:15:49AM -0500, Richard Eisenberg wrote:
> On Feb 7, 2016, at 10:11 AM, Tom Ellis <tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk> wrote:
> > No one has suggested anything less contrived, so I'm going to assume this
> > encompasses all use cases for the new type.  in which case may I make a
> > counter proposal:
> > 
> >    Give Prelude.($) a truthful type of '(a -> b) -> a -> b' and put the
> >    generalized version in a separate module, at least for now?
> 
> I would agree with this... except that the version of ($) in base in 7.8
> and 7.10 already *was* generalized in this way.  But no one got as itchy
> about the OpenKind that appears in 7.10's `:i $` as they are about the
> guck that appears in 8.0's `:t ($)`.  So moving it out now would break
> code in the wild like https://ghc.haskell.org/trac/ghc/ticket/8739

This sounds a bit like throwing good money after bad.  The levity
polymorphic behaviour of ($) in 7.8 and 7.10 was not advertised in its type,
nor in the documentation:

    https://hackage.haskell.org/package/base-4.8.2.0/docs/src/GHC.Base.html#%24

If people were relying on it to do something non-Haskell 2010, undocumented,
GHC specific, then that's sad for them.  But there are probably one hundred
times as many people (literally) who would be startled to see the "correct"
type pop up in GHC 8.

Why not move the polymorphic version to a library and all those who really
need it can get it from there.  In time, when it has demonstrated itself to
be an indisposable generalization, then it can be moved to base.

> Just to amplify this point: the generalization of ($) that we are debating
> **is not new**.  The way it's rendered in GHCi is new, however.

Sure I get that.  It's just that few really knew that's how it was, because
it wasn't advertised as being as it was, so few could question it :)

(I've known for a while ($) has some magic around runST, but two days ago
was the first time I heard about it being levity polymorphic.)

Tom


More information about the Haskell-Cafe mailing list