Doing this via pattern matching is fine; you could simplify your code though by using
pairMaybe :: Maybe a -> Maybe b -> Maybe (a,b)
pairMaybe (Just a) (Just b) = Just (a,b)
pairMaybe _ _ = Nothing
That being said, your function actually just lifts the (,)
function (which creates 2-tuples) into the Maybe
monad, so you could also write
pairMaybe :: Maybe a -> Maybe b -> Maybe (a,b)
pairMaybe = liftM2 (,)