[Haskell-beginners] Usage of $

Rein Henrichs rein.henrichs at gmail.com
Mon Jun 8 19:06:57 UTC 2015


Of course not. What a silly thing to suggest. I'm saying that parsing is
not relevant to the behavior of ($). The parser can't tell the *semantic*
difference between $ and any other operator.

On Mon, Jun 8, 2015 at 11:02 AM Mike Meyer <mwm at mired.org> wrote:

> Are you saying that GHC doesn't have a haskell parser?
>
>
> On Mon, Jun 8, 2015 at 12:06 PM, Rein Henrichs <rein.henrichs at gmail.com>
> wrote:
>
>> The point is that there is no parsing happening here. Just evaluation.
>>
>> On Mon, Jun 8, 2015 at 3:20 AM Mike Meyer <mwm at mired.org> wrote:
>>
>>>
>>> On Jun 8, 2015 05:01, "Martin Vlk" <martin at vlkk.cz> wrote:
>>> >
>>> > Mike Meyer:
>>> > > s mp $ n - 1 parses as s mp (n - 1)
>>> > > s mp n - 1 parses as (s mp n) - 1
>>> >
>>> >
>>> > Hi, I think it is misleading to say that $ "parses" to something.
>>>
>>> Which is why I didn't say such a thing. The two sentences show how the
>>> expressions he was having trouble with are parsed.
>>>
>>> > ($) is an infix operator with type:
>>> >
>>> > ($) :: (a -> b) -> a -> b       -- Defined in ‘GHC.Base’
>>> > infixr 0 $
>>> >
>>> > So what it does is it takes a function on the left hand side and
>>> applies
>>> > it to the second argument on the right hand side. The trick is it has
>>> > the lowest possible precedence value (0) so everything on the right
>>> hand
>>> > side will be evaluated before applying the function on the left.
>>>
>>> Which explains why the expression containing a $ parses as it does,
>>> which is also useful information.
>>> _______________________________________________
>>> Beginners mailing list
>>> Beginners at haskell.org
>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>>
>>
>> _______________________________________________
>> Beginners mailing list
>> Beginners at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>
>>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150608/47eec0d7/attachment.html>


More information about the Beginners mailing list