News for hackers. Stuff that matters.
Re:Functors, applicatives, and monads in pictures by GhotiFish on Sunday May 19, 2013 @12:43AM (#5731830)

   > (+) <$> (Just 5)
   Just (+5)
   > Just (+5) <$> (Just 4)
   ERROR ??? WHAT DOES THIS EVEN MEAN WHY IS THE FUNCTION 
     WRAPPED IN A JUST
A functor takes a function, and applies it to the inside of a context, but all of a sudden now a functor can't take a function and apply it to the inside of a context.

No, that will never make sense. Sorry. Haskell is hard.

edit: oh, it's in a just value, I didn't notice that the first time I read it, for... some reason.

Re:Functors, applicatives, and monads in pictures by chongli on Sunday May 19, 2013 @04:35PM (#5734295)
>A functor takes a function, and applies it to the inside of a context, but all of a sudden now a functor can't take a function and apply it to the inside of a context.

Where you're getting mixed up is in the distinction between Functors and Applicative Functors. You can think of an Applicative Functor as one which allows you to apply its contents to other things. One function which must be defined for all Applicative Functors is:

    (<*>) :: f (a -> b) -> f a -> f b
Looking at the type signature, this is a function of two arguments. The first argument is an Applicative Functor containing a function. The second argument is the same functor containing a value to which that function may be applied. What does this function do? It simply applies the function and returns the result, wrapped in the same Functor. Thus:

    Just (+5) <*> Just 4
    >>> Just 9
This is very much analogous to typical function application:

   (+5) 4
   >>> 9
Which is why the function (<*>) is usually pronounced "ap" or "applied over".
Re:Functors, applicatives, and monads in pictures by antninja on Sunday May 19, 2013 @06:47AM (#5732495)
"Just (+5)" is not a function. This would have worked with:

(+5) <$> (Just 4)

Re:Functors, applicatives, and monads in pictures by tel on Sunday May 19, 2013 @11:44AM (#5733161)
Or Just (+5) <*> Just 4 as it turns out.
Re:Functors, applicatives, and monads in pictures by usea on Sunday May 19, 2013 @01:44AM (#5731983)
I stumbled on the exact same thing. Eventually I just moved on without knowing what I was missing. Your post pointed it out to me, thanks.