Haskell standard function (or simple composition) for "mjoin"? -
this seems long shot, i've had need following:
mjoin :: (monoid b, monad m) => m b -> m b -> m b mjoin b = a' <- b' <- b return $ mappend a' b'
the example use this:
> mjoin (just [1,2,3]) (just [4, 5, 6]) [1,2,3,4,5,6] > mjoin (just [1,2,3]) nothing nothing > mjoin nothing (just [4, 5, 6]) nothing
in other words, if either parameters nothing
, return nothing
. else, return just
, appended values.
is there standard function or simpler formulation, perhaps >>=
?
perhaps this:
mjoin :: (monoid b, monad m) => m b -> m b -> m b mjoin = liftm2 mappend
Comments
Post a Comment