New type of ($) operator in GHC 8.0 is problematic
Takenobu Tani
takenobu.hs at gmail.com
Wed Feb 17 13:09:59 UTC 2016
Hi Alexander,
> 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.
interesting idea.
It's ":t" 's verbose representation mode.
The ghci represents true type (not lie) and
beginners may intuitively understand the relation between
Foldable type class and instances.
Beginners will be overcome FTP more easily.
> 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.
It's one of the options.
But I feel that Levity (or RuntimeRep) is more deep than the type class.
They may feel difficult to understand the difference of two patterns in ($).
(If it will be long, it's better to separate thread =) )
Regards,
Takenobu
2016-02-16 16:28 GMT+09:00 Alexander Kjeldaas <alexander.kjeldaas at gmail.com>
:
>
>
> 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/20160217/558f3103/attachment.html>
More information about the ghc-devs
mailing list