[Haskell-beginners] ap = liftM2 id

martin martin.drautzburg at web.de
Thu Mar 26 21:48:37 UTC 2015


Am 03/26/2015 um 09:33 PM schrieb Andres Löh:

I'll have to think about this. But other than that I am laughing my ass off after reading your paper about "Konjunktiv
III". I can hardly type.


> There's no such thing as a fixed arity of a function in Haskell. The
> type of id is
> 
>> id :: a -> a
> 
> If you instantiate "a" with "b -> c", then it becomes
> 
>> id :: (b -> c) -> b -> c
> 
> and it suddenly takes two arguments. In fact, it then behaves like
> function application. Try
> 
>> id not True
> 
> or
> 
>> not `id` True
> 
> and you'll see that it works as if you had used function application
> or $ instead. So ap lifts function application, and if it helps, you
> can think of it as instead being defined as
> 
>> ap = liftM2 ($)
> 
> Cheers,
>   Andres
> 
> 
> On Thu, Mar 26, 2015 at 9:18 PM, martin <martin.drautzburg at web.de> wrote:
>> Hello all,
>>
>> can someone explain
>>
>> ap  =  liftM2 id
>>
>> to me? liftM2 wants a binary funcation
>>
>> liftM2  :: (Monad m) => (a1 -> a2 -> r) -> m a1 -> m a2 -> m r
>>
>> but id is unary. How does this work?
>> _______________________________________________
>> Beginners mailing list
>> Beginners at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
> 
> 
> 



More information about the Beginners mailing list