ifMaybe
import qualified Data.Vector as V
ifMaybe :: Bool -> b -> Maybe b
ifMaybe p x = if p then Just x else Nothing
main = do
let vec = V.fromList [1,2,3,4,5]
print $ V.mapMaybe (\x -> ifMaybe (x < 4) (show x ++ "p")) vecINFO
import qualified Data.Vector as V
ifMaybe :: Bool -> b -> Maybe b
ifMaybe p x = if p then Just x else Nothing
main = do
let vec = V.fromList [1,2,3,4,5]
print $ V.mapMaybe (\x -> ifMaybe (x < 4) (show x ++ "p")) vec