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

Popular posts from this blog

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -