[Haskell-cafe] do vs. pattern matching

Donn Cave donn at avvanta.com
Sun Aug 5 04:06:01 CEST 2012

On Sat, Aug 4, 2012 at 7:05 AM, Alexander Solla <alex.solla at gmail.com> wrote:
> On Fri, Aug 3, 2012 at 11:34 PM, Matthew <wonderzombie at gmail.com> wrote:
>> With do notation, I can write something like this:
>>         do
>>           foo <- callFoo x
>>           bar <- callBar x
>>           return (baz)
> The short answer is to write a "one liner" using (>>=) and (>>), unless you
> need to bind more than one value to a variable.  In that case, you should
> use an applicative interface, if available and otherwise possible, and
> finally do-notation.

But the longer answer would be, it depends!  Right?  The `do' notation
is clear and easy to follow; it's low maintenance - even if you have
nothing to bind right now, if that comes up in the future, it will
drop right into that `do' block;  it's classic Haskell that doesn't
need any explaining to (hardly) anyone.  Maybe it's your last choice,
maybe it's my first.


More information about the Haskell-Cafe mailing list