Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.haskell > #226

Re: cascading if conditions

From usenet@mkarcher.dialup.fu-berlin.de (Michael Karcher)
Newsgroups comp.lang.haskell
Subject Re: cascading if conditions
Date 2012-06-16 17:23 +0000
Organization Freie Universitaet Berlin
Message-ID <a43tnqFlk8U1@mid.uni-berlin.de> (permalink)
References <op.wfzcfp2bazwite@akasham> <7xk3z7wzax.fsf@ruckus.brouhaha.com>

Show all headers | View raw


Paul Rubin <no.email@nospam.invalid> wrote:
> I don't know if this is standard:
> 
>   import Data.Maybe (catMaybes)
> 
>   head . catMaybes $ [fna, fnb, fnc, Just defaltval]

Another solution (relying on the MonadPlus instance of Maybe):

 import Control.Monad (msum)

 msum [fna, fnb, fnc, Just defaultval]

Regards,
  Michael Karcher

Back to comp.lang.haskell | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

cascading if conditions blufox <blufox@gmail.com> - 2012-06-15 22:05 -0700
  Re: cascading if conditions Paul Rubin <no.email@nospam.invalid> - 2012-06-15 23:23 -0700
    Re: cascading if conditions blufox <blufox@gmail.com> - 2012-06-15 23:31 -0700
    Re: cascading if conditions usenet@mkarcher.dialup.fu-berlin.de (Michael Karcher) - 2012-06-16 17:23 +0000
      Re: cascading if conditions Paul Rubin <no.email@nospam.invalid> - 2012-06-16 10:32 -0700
        Re: cascading if conditions Paul Rubin <no.email@nospam.invalid> - 2012-06-16 11:43 -0700
      Re: cascading if conditions blufox <blufox@gmail.com> - 2012-06-16 22:27 -0700
  Re: cascading if conditions chb hemma <chb@home.se> - 2012-06-24 23:36 +0200

csiph-web