thoughtbot / maybe_haskell

Programming without Null
http://maybe-haskell.com
Other
80 stars 4 forks source link

A question on types / currying #75

Closed craigdallimore closed 9 years ago

craigdallimore commented 9 years ago

Hello! Loving the book.

However, I've got a little bit confused at the end of Functor > Curried Form > Partial Application (link), at this part:

maybeName = fmap userUpperName (findUser someId)

What really happened is that fmap was first applied to the function userUpperName to return a new function of type Maybe User -> Maybe String.

If I understand correctly, it will not receive a Maybe until it evaluates the next part of the expression - how does it know that it is to return Maybe User -> Maybe String (and not - for example - IO User -> IO String) until it evaluates (findUser someId)?

Would it not be returning something along the lines of Functor f => f User -> f String?

Thanks! :)

pbrisbin commented 9 years ago

Hey, sorry I missed this! If you are still confused on this point I'd be happy to explain further. Feel free to reopen the issue and I should be able to make a larger reply by Monday at the latest.

craigdallimore commented 9 years ago

Hi @pbrisbin I think I'm satisfied with the explanation of fmap for now, thanks :)