[Haskell-beginners] how to skip pattern match error when applying a mapM_

Daniel Trstenjak daniel.trstenjak at gmail.com
Tue Jan 17 18:06:11 UTC 2017

Hi Frederic,

On Tue, Jan 17, 2017 at 05:34:05PM +0000, PICCA Frederic-Emmanuel wrote:
> I tought that was the purpose of the Monad to avoid writting these boillerplate ?
> What I am missing ?

You don't pattern match on 'Just' but just write:

   gamma <- get_position' (h5gamma d) 0
   delta <- get_position' (h5delta d) idx
   wavelength <- get_position' (h5wavelength d) 0

If e.g. 'gamma' is 'Nothing', then the following expressions aren't evaluated
and the whole "do-block" returns 'Nothing'.


More information about the Beginners mailing list