
michael rice wrote:
Got it! I figured there must be some way to unpack it.
If you peek at the thread about getting a value out of IO [1], you will see some similarities. If you look at my response [2], you will see that the functions I suggested for IO are exactly the same as the functions you may want to consider for this case! fmap, liftA, liftM, (<$>) :: Functor f => (a -> b) -> (f a -> f b) (<*>), ap :: Applicative f => f (a -> b) -> (f a -> f b) (=<<) :: Monad m => (a -> m b) -> (m a -> m b) So, for Maybe, you have: (<$>) :: (a -> b) -> (Maybe a -> Maybe b) (<*>) :: Maybe (a -> b) -> (Maybe a -> Maybe b) (=<<) :: (a -> Maybe b) -> (Maybe a -> Maybe b) You will find that a *lot* of the functions you learn in Haskell are actually very general, and once you internalize what they *really* do, you will suddenly have entire classes of problems solved by just a few functions. - Jake [1] http://www.haskell.org/pipermail/haskell-cafe/2009-April/059834.html [2] http://www.haskell.org/pipermail/haskell-cafe/2009-April/059852.html