> Here a reduction of my problem
> values :: IO [IO (Maybe Int)]
> values = do
> let v = [Just 1, Just 2, Just 3, Nothing, Just 5, Nothing, Just 7] :: [Maybe Int]
I would let the compiler deal with the type, i.e. skip the ` :: [Maybe Int]`.
> return $ map return v
Wrapping the list *and* its items in `IO` seems excessive. Would it not
be easier to have `values :: IO [Maybe Int]`?
> main :: IO ()
> main = do
> vs <- values
> nvs <- mapM_ go vs
> print nvs
> go :: IO (Maybe Int) -> IO Int
> go v' = do
> Just v <- v'
> return v
> when I run this script, I get a runtime error
> picca@diffabs6:~/tmp$ runhaskell test.hs
> test.hs: user error (Pattern match failure in do expression at test.hs:13:10-15)
> What I want is a go method which skip silently the (IO Nothing) values.
> so when used in the mapM_ it return only the values which are returned
> by the IO (Maybe Int) (stored in the values)
You can't, not with the route you've taken here. It would be the
equivalent of skipping the `else` clause of an `if` statement. I suggest
you rethink your approach of how to remove (filter out) the `Nothing`
items in the list.