New type of ($) operator in GHC 8.0 is problematic

Alexander Kjeldaas alexander.kjeldaas at gmail.com
Tue Feb 16 07:28:30 UTC 2016


On Fri, Feb 5, 2016 at 2:16 PM, Takenobu Tani <takenobu.hs at gmail.com> wrote:

> Hi,
>
> I'll worry about the learning curve of beginners.
> Maybe, beginners will try following session in their 1st week.
>
>   ghci> :t foldr
>   ghci> :t ($)
>
> They'll get following result.
>
>
> Before ghc7.8:
>
>   Prelude> :t foldr
>   foldr :: (a -> b -> b) -> b -> [a] -> b
>
>   Prelude> :t ($)
>   ($) :: (a -> b) -> a -> b
>
>   Beginners should only understand about following:
>
>     * type variable (polymorphism)
>
>
> After ghc8.0:
>
>   Prelude> :t foldr
>   foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b
>
>
If the output was the following it would be more understandable (and more
encouraging!)

"""
Prelude> :t foldr
foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b
For example:
foldr :: (a -> b -> b) -> b -> [a] -> b
foldr :: (a -> b -> b) -> b -> Maybe a -> b
foldr :: (a -> b -> b) -> b -> Identity a -> b
foldr :: (a -> b -> b) -> b -> (c, a) -> b
and more
"""

It is easy to see a pattern here.  The order of the instances used could be
the load order, so the ones from Prelude would come first.



>   Prelude> :t ($)
>   ($)
>     :: forall (w :: GHC.Types.Levity) a (b :: TYPE w).
>        (a -> b) -> a -> b
>
>
I'm not sure how this would work here, but when Levity is *, this should
collapse into the old syntax, so:

"""
Prelude> :t ($)
($) :: <"unreadable blurb">
For example:
($) :: (a -> b) -> a -> b
($) :: forall a (b :: #). (a -> b) -> a -> b
"""

At least one of those lines should be understandable.

Alexander
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20160216/80282f89/attachment.html>


More information about the ghc-devs mailing list