[Haskell-beginners] Trivial function of type (a -> b) -> Maybe a -> Maybe b

Eugen Zagorodniy e.zagorodniy at gmail.com
Wed Jan 13 09:44:26 EST 2010


Greetings!

I looked at documentation of Maybe type and suprisingly found no
function like

maybize             :: (a -> b) -> Maybe a -> Maybe b
maybize f Nothing   =  Nothing
maybize f (Just x)  =  Just (f x)

I believe there should be a good reason for absence of such function,
say:

1) there is an idiomatic way (probably utilizing higher level
abstractions) of doing the same what 'maybize' does,
2) no one really needs it... except me,
3) ?..

Did I miss something? (It is rather about curiosity than a real problem
though).

Thanks in advance for any comments!


More information about the Beginners mailing list